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;

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 814 views
  • 0 likes
  • 2 in conversation