Help using Base SAS procedures

Getting away from PROC IMPORT

Accepted Solution Solved
Reply
Super Contributor
Posts: 268
Accepted Solution

Getting away from PROC IMPORT

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?


Accepted Solutions
Solution
‎11-15-2016 07:54 AM
Super User
Posts: 3,106

Re: Getting away from PROC IMPORT

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


All Replies
Solution
‎11-15-2016 07:54 AM
Super User
Posts: 3,106

Re: Getting away from PROC IMPORT

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.

Super User
Posts: 10,500

Re: Getting away from PROC IMPORT

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.

 

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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