BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
NinaWestern
Obsidian | Level 7

This should be fairly simple.

Trying to create a new variable for two groups separately.

For group a:

if diagn =0 or 1, then comorb=0; 

if diagn >=2 then comorb=1;

 

For group b:

if diagn =0 then comorb=0; 

if diagn >=1 then comorb=1;

 

The syntax for group2 works fine.

 

Here is my syntax for group1:

data x;

set x;

if group='a' then do;

if diagn =0 or diagn=1 then comorb=0;

else if diagn >=2 then comorb=1;

end;

 

This syntax does not calculate the comorb variable at all.

 

Any ideas on what might be wrong and how to correct it? 

Thank you! 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
NinaWestern
Obsidian | Level 7
Yes, there is a variable named "group", with a and b as its values.

The log has no errors.

View solution in original post

4 REPLIES 4
biopharma
Quartz | Level 8
Can you create a sample dataset with what you HAVE? Then present another dataset with what you WANT. Look how some posters have done this in a datastep and show.

If I were to take a wild guess, this condition is not met as specified.
if group='a' then do;

Try specifying this as
if upcase(group)="A" then do;
Shmuel
Garnet | Level 18

You haven't posted neither the log nor sample of your imput,

so it is impossible to know what is the mistake.

 

Is there a variable  named GROUP in your input dataset ?

 

NinaWestern
Obsidian | Level 7
Yes, there is a variable named "group", with a and b as its values.

The log has no errors.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 535 views
  • 0 likes
  • 4 in conversation