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!
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 ?
Please post the whole log of your data step.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.