Hi all,
I am trying to read in multiple csvs with headers on the first line using wildcards in the infile command. I heard that to skip the first line in the files one could use EOV however I didn't get a chance to figure out how it works.
If i just say the piece of code below, I still get the headers imported.
infile '\\*_20160831*.csv' dlm=';' lrecl=10000 dsd missover eov=eov firstobs=2;
if eov then input;
input
column_1
;
If I however use the piece of code below it works.
infile '\\*_20160831*.csv' dlm=';' lrecl=10000 dsd missover eov=eov firstobs=2;
input @;
if eov then input;
input column_1;
What does this input @; command do? I could not find any documentation on it ...
Thank you.
Trailing @ means that you are not done reading this line yet. SAS keeps the line current and it is available for another INPUT statement on the same iteration of the data step.
Here is a simple example that uses that to read in multiple observations from one line.
data mydata;
input id $ @;
do year=2010 to 2015 ;
input cost @;
output;
end;
cards;
Milk 1 2 3 4 5 6
Beer 2 3 4 5 6 7
;
The reason that you need it is because the EOV flag is not set until SAS sees that you are opening another data file and it does not know this until you try to read from it. So you need the INPUT statement to set the EOV flag, but you don't want to try to read hte column headers into your variables. So you read the line, but do not try to read any variable values by using the bare INPUT statement with only the trailing @ pointer control command.
Trailing @ means that you are not done reading this line yet. SAS keeps the line current and it is available for another INPUT statement on the same iteration of the data step.
Here is a simple example that uses that to read in multiple observations from one line.
data mydata;
input id $ @;
do year=2010 to 2015 ;
input cost @;
output;
end;
cards;
Milk 1 2 3 4 5 6
Beer 2 3 4 5 6 7
;
The reason that you need it is because the EOV flag is not set until SAS sees that you are opening another data file and it does not know this until you try to read from it. So you need the INPUT statement to set the EOV flag, but you don't want to try to read hte column headers into your variables. So you read the line, but do not try to read any variable values by using the bare INPUT statement with only the trailing @ pointer control command.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.