SAS CornerMultiple Records per ObservationBy Garvii Thomas, Research and Statistical Support Services ConsultantA question that was asked of me recently was to show how SAS can deal with an external file that has multiple records per observation. The person had a huge dataset in which the observation took up more than one line. I then proceeded to show him how easy it was in SAS with a similar program to the one I'm about to show you. After making a slight adjustment to the insurance dataset and calling it Insurance2.dat each patients' information now takes up two lines as shown below.
The key to accomplishing this is controlling when each record loads. This is controlled by having a second input statement to deal with in data that is on the second line for each observation. This allows each line of the observation to be loaded independently ( a third input statement will be needed if there was a third row of records and so forth).
Lets now take a look at our output:
Once again an expansion of this and other concepts in SAS will be covered in my SAS short course series ( http://www.unt.edu/rss/ ) for the Spring Semester here at UNT. Check out this paper on debugging code in SAS: http://support.sas.com/sassamples/papers/debug101_03jan.pdf |