Mike 35 male tall smoker
Sara 26 female short smoker
Monica 24 female short nonsmoker
The first line has basic information about the observation, then there are numerous variables( they are test scores values from 1-6 )
I found out that only the first five scores are needed and to delete everything else
How do I just retain the first line and only the first 5 scores and then move to the second observation (Sara)
this is how I want my output:
Mike 35 male tall smoker 12312
Sara 26 female short smoker 12222
Monica 24 female short nonsmoker 12415
Wow, thanks so much!
How does it work?
I am looking into compress function but still dont know how does it work?
lets say I want to read the first 5 observation of each line, do i just create a do loop?
Message was edited by: bluelion
Here is how it works. The datastep reads in the file data.txt, which we are saying is space delimited. It then reads the first variable into name. The @@ says don't go to the next line yet. SAS doesn't have an isnumeric function, so we test it by removing the numbers with compress and seeing if we changed it. If not, then we read in the rest of the variables (the / says go to the next line for the rest of the variables).
Not sure what you mean by the first 5 observations of each line. The data step has a built in loop, so you won't need a do loop. Do you mean you want to read in only 5 records total?