Appending csv files in SAS -
i have bunch of csv files. each has data different period:
filename file1 'jan2011_price.csv'; filename file2 'feb2011_price.csv'; ...
do need manually create intermediate datasets , append them together? there better way of doing this?
solution
from documentation preferable use:
data allcsv; length fileloc myinfile $ 300; input fileloc $ ; /* read instream data */ /* infile statement closes current file , opens new 1 if fileloc changes value when infile executes */ infile filevar=fileloc filename=myinfile end=done dlm=','; /* done set 1 when last input record read */ while(not done); /* read input records */ /* opened input file */ input col1 col2 col3 ...; output; end; put 'finished reading ' myinfile=; datalines; path-to-file1 path-to-file2 ... run;
to read bunch of csv files single sas dataset, can use single data step described in sas documentation here. want second example in section uses filevar=
infile option.
there should no reason create intermediate datasets.
Comments
Post a Comment