/* purpose: Shows how to read in multiple raw data files in one data step. This example reads fixed columns data, but it can be modified to read other kinds of raw data (e.g. free format data).notes: comments in CAPITALS indicate parts you should change to make this program work with your data. */
* WARNING! This fileref MUST NOT refer to your input data or any; * existing file. This would OVERWRITE your file and cause’; * you to LOSE YOUR DATA; filename dummy ‘c:dummy.xxx’;
* data step to read in data; data mydata;
* inname will store the NAMES of the raw data files to be read; length inname $ 100; * This reads the NAMES of the raw data files from the "cards" ; * statement into inname; input inname $;
* the following infile statement reads from each of the ; * raw data files listed after the cards statement; infile dummy filevar=inname end=EOF; do until (EOF);
* PUT YOUR INPUT STATEMENT HERE TO READ IN YOUR DATA; input year 1-4 name $ 6-28 party $ 30-34 born 35-38 died 40-43 age 45-46 stborn $ 48-49 stelec $ 51-52 religion $ 54-65 elecvote 67-69 popvote 71-78;
* DO ANY PROCESSING OF THE DATA HERE (E.G. COMPUTING NEW VARIABLES);
* make sure to have an output statement; output; end;
* PLACE THE NAMES OF YOUR INPUT FILES AFTER THE CARDS STATEMENT; cards; c:winners1.txt c:winners2.txt run;
* use proc print to verify that all the data files were read; * CHANGE WINNERS TO THE NAME OF YOUR SAS DATA FILE; proc print data=mydata; var year; run;