The first line is the length statement telling SAS to create a space in the PDV that is 17 bytes long (SAS stores each letter in 1 byte of memory) and for character data. If you don't specify the length then the length is defined by the first string read in, which in this case is 'One'. This would cause a length of 3 bytes to be assigned to x and all subsequent values of x, be truncated to 3 bytes.
If you don't know what the PDV is or if you just want a better understanding of the SAS datastep here is a walkthrough:
The following part tells SAS that a variable 'val' is going to be read in as a standard numeric - which will be assigned the default of 8 bytes for numeric data. The double trailing @'s are used to hold the input record for the execution of the next input statement across iterations of the DATA step. I find it useful for saving space when writing code that contains few variables with many observations.
Code:
input val @@;
Finally, the cards statement is same as the datalines statement; it specifies that data is to be read in. The only difference between datalines and cards is the name. Cards has been used since the days of yore when computers where programmed using punch cards. I think SAS just decided it didn't make sense to newer programmers so gave it a more intuitive name. I personally prefer cards because 4 letters shorter - yes, I really am that lazy
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.