



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
How to create multiple observations from the same record using sas, including examples of single and multiple input statements, line pointer controls, and variables list input. It also covers reading data from external files and accessing permanent sas data sets.
Typology: Study notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!




*****Creating multiple observations from the same record***** Use the double trailing @@ -- this is another of the pointer controls @@ not only prevents a new record from being read into the buffer when a new INPUT statement is encountered, but it also prevents the record from being released when the program loops back to the top of the DATA STEP -- Carefully read section 2.13 in your textbook. Let’s look at some examples involving the census data of the 50 states and the falls data. (See Program SAS_Lec04_input_01.sas) (See Program SAS_Lec04_input_02.sas) ****Reading multiple records to create a single observation**** Suppose the data is recorded as follows: 1023 David Shaw red 189 195 1049 Amelia Serrano yellow 145 124
There are four ways to read this data;
Reading Data from External Files This requires the use of another SAS “holy” word, namely INFILE The following statement must be placed in the “Data Step”, before the “INPUT” statement. infile 'E:\My Current Work Files\stat321-my data files\census.dat'; (See Program SAS_Lec04_census_data1.sas) Re: the census data examples. Creating Permanent SAS Data Sets for Future Use This again, introduces a new SAS “holy” word, namely LIBNAME. This statement must be place outside the “Data Step”; it is usually best to place it early in the program, up front near the “OPTIONS” statement. Libname jim "E:\My Current Work Files\stat321-mysdl"; Note, that the use of the library reference name “jim”. This is used in SAS’s two level naming system. This level, i.e. the first level has meaning only in the current program. (See Program SAS_Lec04_census_data2.sas) (See Program SAS_Lec04_census_data3.sas) Call attention the log file in the examples.
Accessing Permanent SAS Data Sets You must first specify the location and library reference name in the LIBNAME statement. Then within the Data Step, use the set statement: Data newone; Set librefname.datasetname; Proc contents; (See Program SAS_Lec04_census_data4.sas) Note: to bring into our work area an existing SAS data set, we use the “Set” statement within the Data Step. How do we know what’s in a permanent SAS data set? For that, we will need a procedure called “Proc Contents”.