Learning SAS? Welcome to the exclusive online community for all SAS learners.

very basic infile

Occasional Contributor
Posts: 6

very basic infile

There is no result and no errors. There are too many variables, so I don't want to write all variables, what is the efficient way  to read all variables name from CSV file.


filename tax1 '~/data/0001.csv';
    data tax;
    infile tax1;

proc print data=tax;

Posts: 429

Re: very basic infile

Hi, @pingsu. You might just take the easy way out and use the Import CSV task and then you can review the code once the file has been imported successfully! That's what I would do because I enjoy seeing how the Task chose to implement the code.



Super User
Posts: 23,724

Re: very basic infile

If you use Proc Import or a Import Task you will get the code and can then customize the code to your requirements.


If using Proc Import, I recommend setting GUESSINGROWS option high to allow SAS to scan all rows before determine a variable type. This means its more likely to read the data accurately. 


I'm not sure you're specifying your filename correctly as well for SAS UE. Assuming you're using SAS UE the code below is more likely correct. Otherwise if using SAS for Academics On Demand then you may need a different filename. 


proc import data='/folders/myfolders/data/0001.csv' dbms=csv replace;
Super User
Super User
Posts: 9,599

Re: very basic infile

It sounds like your input datafile is innefficiently exported from the previous step if you have many variables, therefore any subsequent steps will be innefficient as well.  Me, I would do my upmost to get data in the format I want - create import agreement, get signoffs etc.  If file format can't be changed then explain additional costs etc.  At the end of the day you have to work with it.

Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation