and thank you in advance for any help you can offer as I am relatively new to SAS.
I'm attempting to read into SAS a file of the following format:
001DATA...
002DATA...
RSSDATA...
001DATA...
002DATA...
RSSDATA...
001DATA...
002DATA...
001DATA...
002DATA...
RSSDATA...
Everyone in this file has an "001" and an "002" sub-record. Some, but not all, have an "RSS" sub-record (i.e., the first three lines in the above example represent data from one subject). An issue arises from the fact that not everyone in the file has an RSS sub-record, and as a result, those that don't are simply deleted when I run the program outlined below (i.e., their 001 and 002 sub-records are removed...rows 7 and 8 in the above example). The end result is that ~1/3 of my sample gets deleted via this process. I'm using the following code (for brevity I've not included all variables, and no, they're not all named "variable":):
INPUT @1 type $CHAR3. @;
RETAIN many variables;
IF type = '001' THEN DO;
INPUT @4 variable $CHAR8.
@12 variable $CHAR1.
;
RETURN;
END;
ELSE IF type = '002' THEN DO;
INPUT @4 variable $CHAR35.
;
RETURN;
END;
ELSE IF type = 'RSS' THEN DO;
INPUT @4 variable $CHAR6.
@10 variable $CHAR1.
;
OUTPUT filename;
END;
RUN;
Is there a way to prevent these deletions from occurring? Essentially what I want (in the output file) is for each row to represent one subject, and include their 001, 002, and if present, their RSS data.
Thanks again for any guidance you may be able to provide!