BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GreggB
Pyrite | Level 9

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?

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

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.

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

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.

ballardw
Super User

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.

 

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1344 views
  • 1 like
  • 3 in conversation