05-10-2016 09:25 AM - last edited on 05-10-2016 10:30 AM by LinusH
I am new in SAS. Recently I came across a SAS code, Can you please explain me:-
data _null_; /* don't need dataset*/
infile in; /* raw file in */
input; /* read a record */
put _infile_; /* put buffer in log*/
if _n_ > 50 then /* stop after 50 */
stop; /* adjust as needed */
run; /* end of step */
What is exactly the role/function of input As it is not declaring any variable?
Thanks and Regards,
05-10-2016 09:31 AM
This form of input reads the whole line of input data without assigning values to any variable.
Maybe this example helps to better understanding:
a v f
1 3454 34543
a 35 354
05-10-2016 09:35 AM
Infile reads a line from the datafile. The code needs to do this to know how many observations (_n_) its on. It doesn't need to create any variables and increment the _n_ for the check later on. Normally you would have an input statement which reads data and puts it into variables, but as your not saving the output dataset, nor using it in anyway other than to only output the first 50 rows of data, then its not needed.
05-10-2016 09:55 AM
The purpose of the program is to dump 50 lines of the incoming data file to get a sense of what the data looks like.
_INFILE_ is a copy of the latest line from the incoming data file.
INPUT is necessary (even if no variables are being input) to update _INFILE_, allowing it to move from line line of data to the next. Without INPUT, the program would remain stuck on the first line of data from the incoming file.