Joined: 06 Jun 2008 Posts: 8417 Location: Dubuque, Iowa, USA
Quote:
My understanding is that SAS is reading two records as one because of NUM2 being ".".
Your understanding is very wrong. You are telling SAS to read from a separate line (record) every time it finds EMPNAME = 'EDGAR '. Hence it reads the first line and keeps it. The second line is read, then the third line is read inside the IF statement and all that data is deleted. The fourth line is read, then the fifth line is read inside the IF statement and again the data is deleted .... etc. SAS allows you to re-read a data line but you must use a trailing @ sign in your INPUT statement.
Something like this is what you want:
Code:
DATA TEMP ;
INPUT @001 EMPID 6.
@007 EMPNAME $10.
@017 EMPAGE 2.
@019 NUM 2. @ ;
IF EMPNAME = 'EDGAR '
THEN DELETE ;
OUTPUT RI863B ;
Why do you want to read columns 19-20 as 2 separate variables? NUM and NUM2 will have the same values every time.
Why do you read NUM2 and then immediately delete the observation?
Why do your DATA step and your OUTPUT have different names?
I would usually code this up as
Code:
INPUT @007 EMPNAME $10. @ ;
IF EMPNAME =: 'EDGAR' THEN DELETE;
INPUT @001 EMPID 6.
@017 EMPAGE 2.
@019 NUM 2. ;
With SAS you don't have to read data from column 1 on - you can pick and choose. And I'll let you figure out the =: construct yourself (hint: it's in the SAS manual).
Robert already gave you the right info about using trailing @ to read a records more than once.
You showed how your input file looks like. If you could show us what exactly is the output for the above mentioned input datalines, then we could help you with the logic of SAS.