Tuesday, December 19, 2006

Reading CSV files in SAS on UNIX

Each individual Excell work sheet can be converted into CSV or tab delimited files for being read in SAS.

CSV files are in following format (note that commas separate different data points). This format is especially suitable if you have missing data.

12,10,34
6,9,0
78,89,46
2,3,2


To read csv files, use one of the following statements

data new;
infile '/usr2/users/student/mkaushik/shh/data1.csv' dsd;/* change the location of the file */
INPUT rake note pgg ; /* these are variable names of your choice*/
run;

OR

data new;
infile '/usr2/users/student/mkaushik/shh/data1.csv' delimiter=','; /* change the location of the file */
INPUT rake note pgg ; /* these are variable names of your choice*/
run;