BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Sean_OConnor
Fluorite | Level 6

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;
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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?

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Remove the RETAIN statement.

--
Paige Miller
ballardw
Super User

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?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 431 views
  • 3 likes
  • 3 in conversation