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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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