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
Opal | Level 21

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
Opal | Level 21

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

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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