How do I import a CSV file?
Nico Chart_21517
Altair Employee
We recommend using the IMPORT procedure to read delimited files, for example:
/* READING IN CSV type data */ /* For a comma separated text file where the first line contains the variable names */ proc import datafile="input.csv" out=dataset dbms=csv replace; getnames=YES; run;
/* For a semi-colon separated text file where the first line contains the variable names */ proc import datafile="input.csv" out=dataset dbms=csv replace; getnames=YES; delimiter=';' run;
/* WRITING OUT CSV type data */ proc export data=dataset outfile='output.csv' dbms=csv replace; run;
Supported options for the IMPORT and EXPORT procedures can be found in the Altair SLC Reference for Language Elements.
When using the IMPORT procedure this way you should see SAS language source code being generated in the log file. If the IMPORT procedure does not do what you would like it to do then you can copy the source code out of the log and use this as a basis for using existing elements of the SAS langauge to read your text files in whatever format they happen to be in.
Tagged:
0