I recently learned how to use SAS/ACCESS to read Excel files using a LIBNAME statement, which I find to be better than proc import.
Is there a way to do this with csv files, or do I have to use a data step with FILE and INPUT statements?
I don't think so. With the LIBNAME statement there needs to be a database engine or interface to surface the metadata describing the table being read. There is no such engine for CSV. Behind the scenes of PROC IMPORT SAS uses DATA step code to read CSV files.
I don't think so. With the LIBNAME statement there needs to be a database engine or interface to surface the metadata describing the table being read. There is no such engine for CSV. Behind the scenes of PROC IMPORT SAS uses DATA step code to read CSV files.
However if you are reading multiple CSV files of the same format you can use Proc import one time to give you a skeleton program you can modify for reuse.
Proc Import will generate data step code that you can copy from the log and paste (or recall ) into the editor. Save the code. Modify the variable Informats to set expected lengths of character variables over the life of the project, ensure appropriate data/time/datetime informats and formats are set. Add labels. Save the code.
The next time you have a same layout CSV file to read then you only need to change the output SAS data set name and the name of the file on the infile statement. The resulting data sets will have the same structure.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: