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

Hello i have the below data & the program. How come the number of observation in work.test3 has 4 observations instead of 3. 

 

data dbp; 
input id sbp dbp;
datalines;
2001 145 92
2002 130 87
2003 117 78
2004 135 85
2005 145 79
;
run;

 

data
work.test1
work.test2
work.test3;
set dbp;
if sbp gt 140 and dbp gt 90 then output work.test1;
if sbp gt 120 and dbp lt 80 then output work.test2;
else output work.test3;
run;

 

Thank you in advance for your help. 

Akter

 

1 ACCEPTED SOLUTION

Accepted Solutions
Sajid01
Meteorite | Level 14

Hello
Add an else as shown below. It will solve your issue

data
work.test1
work.test2
work.test3;
set dbp;
if sbp gt 140 and dbp gt 90 then output work.test1;
else
if sbp gt 120 and dbp lt 80 then output work.test2;
else output work.test3;
run;

View solution in original post

2 REPLIES 2
Sajid01
Meteorite | Level 14

Hello
Add an else as shown below. It will solve your issue

data
work.test1
work.test2
work.test3;
set dbp;
if sbp gt 140 and dbp gt 90 then output work.test1;
else
if sbp gt 120 and dbp lt 80 then output work.test2;
else output work.test3;
run;
Akter
Obsidian | Level 7
Thank you so much!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 949 views
  • 0 likes
  • 2 in conversation