Good Afternoon,
I'm developing a list of conditions to see if my dataset is producing any non-logical combinations.
For each row we need to look in three columns and if the criteria is met we assign a value of 'Ok', if not we leave it blank.
I can not provide test data but below gives you a snippet of what I'm trying to do.
What I've noticed that in certain cases SAS is assigning a value of 'Ok', even though some records don't meet the criteria to be included.
An example of which is a cod value='C22' which isn't included in my list of clauses but is being assigned as meeting it. Does anyone have an idea why this is the case?
data second;
retain value cod sex ageatdeath;
set first;
*List of all the condition caluses;
if cod="A33" and sex in('M','F') and ageatdeath <=1 then Value='OK';
if cod="A34" and sex in('F') and ageatdeath >=12 and ageatdeath <=55 then value='OK';
if cod="A500" and sex in('M','F') and ageatdeath >=0 and ageatdeath <=2 then value='OK';
if cod="C20" and sex in('M','F') and ageatdeath >=0 and ageatdeath <=2 then value='OK';
if cod="C23" and sex in('M','F') and ageatdeath >=0 and ageatdeath <=2 then value='OK';
run;
I can not provide test data but below gives you a snippet of what I'm trying to do.
Why not? An example that you make up that only uses the variables in the code should not reveal any sensitive information.
Here's an example
data have; input cod $ sex $ ageatdeath; datalines; A33 M 15 A33 F 1 A33 F 15 A33 M 1 A33 O 15 A33 O 1 A34 M 15 A34 F 1 A34 F 15 A34 M 1 A34 O 15 A34 O 1 C20 M 15 C20 F 1 C20 F 15 C20 M 1 C20 O 15 C20 O 1 ;
Example data only needs to demonstrate values used in your question. Some problem descriptions should include whether other values are to be on the observations of the result but values aren't needed, or similar dummy could be included.
What did you think the RETAIN statement was going to do?
Remove the RETAIN statement.
I can not provide test data but below gives you a snippet of what I'm trying to do.
Why not? An example that you make up that only uses the variables in the code should not reveal any sensitive information.
Here's an example
data have; input cod $ sex $ ageatdeath; datalines; A33 M 15 A33 F 1 A33 F 15 A33 M 1 A33 O 15 A33 O 1 A34 M 15 A34 F 1 A34 F 15 A34 M 1 A34 O 15 A34 O 1 C20 M 15 C20 F 1 C20 F 15 C20 M 1 C20 O 15 C20 O 1 ;
Example data only needs to demonstrate values used in your question. Some problem descriptions should include whether other values are to be on the observations of the result but values aren't needed, or similar dummy could be included.
What did you think the RETAIN statement was going to do?
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.