11-09-2012 05:16 PM
I did not understand how to interpret this small program. Could someone help me.
input F @@;
23 63 31 70 67 100 70 104
A B Y F
0 0 1 23
0 0 2 63
0 1 1 31
0 1 2 70
1 0 1 67
1 0 2 100
1 1 1 70
1 1 2 104
11-09-2012 07:24 PM
It is doing exactly what the program is telling it to do.
When A=0 and B=0 and Y=1 it is inputting the first value (23)
it continues to read the same record because of the @@ included in the input statement.
Then when A=0 and B=0 and Y=2 it reads the second record
Then when A=0 and B=1 and Y=1 it reads the third record,
etc., etc., etc.
11-09-2012 07:51 PM
It is a short hand way to enter data when the design factors (A,B,Y) are fixed. Only the value of F needs to be in the input data as the relative order determines what value of A,B,Y goes with the particular value of F.
Things that this program uses that beginners might not understand :
Use of trailing @@ on INPUT statement. This is not strictly needed in the example program because all of the data is on one line so that a single at sign would also work. But the double at sign allows you to split the data across rows when you have more than can fit on a single line of the input program. For example in this program you can split the input data into two or more lines and get the same result.
Use of DO loop with a list of values. In fact with a DO loop in SAS you can actually have in more complex list of values. You can have :
do i=1 to 5,10,15 ;
And it will run the loop 7 times with I being set to 1,2,3,4,5,10,15 .
Use of the OUTPUT statement. This will cause it to generate an observation in the output dataset. So in this case one iteration of the data step will generate 2*2*2=8 output observations.