BookmarkSubscribeRSS Feed
cy_th
Fluorite | Level 6

I am trying to figure out the logic behind some simple programs. Can someone explain the logic behind the output. How is it generated? How is the use of '@' affecting the output in the second program?

data want;
  input a b ;
  input c d ;
  datalines;
1 2 3 4
5 6 7 8
run;
proc print data=want;
run;


data want;
  input a b @;
  input c d ;
  datalines;
1 2 3 4
5 6 7 8
run;
proc print data=want;
run;

 

1 REPLY 1
heffo
Pyrite | Level 9

 When you run the program you can see that the first data step only produce one row. That is because each input statement reads a new line of the input data.

So, in your case:

Read the two first values from the first row. 

Read a new line of input data and read the two first values of that row.

Return to the start of the code and read a new line of input data. Et cetera! 

 

The second data step has a @ in the end of the first input statement. This tells SAS to wait on the first input data row until you tell it otherwise.

So, in your case:

Read two values from the first row.

Then read two more values. 

Return to the start of the code and read a new line of input data. Et cetera! 

 

The @ char is useful if you for example have data that has a different format on different rows. So, if the first value is US you need to use DATE9 as informat and if you have the first value of EUR you use the ISO standard YYMMDD10. Or it might be that the data you have spans more than one row, so row 1 in each set has a name and row 2 has an address. 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 529 views
  • 4 likes
  • 2 in conversation