data Sim1; infile 'Sim.dat'; input id age sex rx time attrib; cos24=cos(2*3.14159/24*time); cos12=cos(2*3.14159/12*time); cos8=cos(2*3.14159/8*time); cos6=cos(2*3.14159/6*time); cos4p8=cos(2*3.14159/4.8*time); sin24=sin(2*3.14159/24*time); sin12=sin(2*3.14159/12*time); sin8=sin(2*3.14159/8*time); sin6=sin(2*3.14159/6*time); sin4p8=sin(2*3.14159/4.8*time); artime=int(time*100); /* remove decimals to get correct sort order */ run;The statement data Sim1 names the data that is loaded in the subsequent statements. Any name beginning with a letter, without punctuation or spaces, and no more than 8 characters long is OK.
The statement infile 'Sim.dat' tells SAS the name of the file containing the data.
The input statement reads the data for six variables from the six columns in the data file and names them. Again, you must limit your variable names to 8 characters.
The remaining statements before the run statement create additional new variables. In this case sinxx and cosxx variables are created for periods between 24 and 4.8 hours using the formula sin(2*pi/period*time) or cos(2*pi/period*time) as described in the primer. The last statement creates a variable suitable for defining the autoregressive structure of this problem; the basic requirement is that this variable appear correctly sorted in the CLASS section of the SAS output. Because of an abberation in the way SAS sorts decimals treated as class variables, shifting of the decimal place to the right (*100) and dropping the remaining decimal places (int) produces an appropriate variable (see random below).