BookmarkSubscribeRSS Feed
JoserT
Calcite | Level 5

Hello,

 

I've been an SPSS user for a long time now and I am just now learning howto use SAS due to a job prospect. I have been asked to complete the following task, but am having a hard time writing the code to flag each student as a numerator and denominator in the attached data set:

 

I was able to complete the two tasks and all the others seem pretty straight forward, but I just can't get my code to work for 'Leave Code: 32'.

 

This is what I wrote based on what instructions say:

 

data cps.hs_students_enrolled;
       set cps.hs_students_enrolled;
       if (leave_code = '32') and (verified_transfer = 'YES' or verified_transfer ='UNKNOWN' or leave_date gt '01feb2016'd) and (enrolled = 0) then denom = 0;
       else if denom = 1;
       if leave_code = '32' and denom = 1 then num = 1;

 

But when I go through and check some of my observations with that code, they don't seem to be flagging correctly. I would appreciate any help on this!

 

I've attached my SAS file and a screen shot of the instructions.

1 REPLY 1
Tom
Super User Tom
Super User

You see to have an extra IF or a missing THEN.

if (leave_code = '32')
 and (verified_transfer = 'YES' or verified_transfer ='UNKNOWN' or leave_date gt '01feb2016'd)
 and (enrolled = 0) then denom = 0;
else denom = 1;