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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.