BookmarkSubscribeRSS Feed
qinghe
Fluorite | Level 6

Hi there,

 

Below is my program:

data hosp_proc12a;

merge hosp12 (in=a) procd;

by record_id;

if a;

if procedure_no=. then procedure_no=0;

else if 5 <= procudure_no <=9 then procudure_no =5;

else if procudure_no >=10 then procudure_no=10;

 

keep record_id indig procedure_no age_grp;

run ;

 

For missing value, I can get a 0. but for other values, there is no change at all. I still have values like 8, 11, 13, 18 in there.

I tried to to define a new variable:

data hosp_proc12a;

merge hosp12 (in=a) procd;

by record_id;

if a;

if procedure_no=. then procd_no=0;

else if 1 <= procudure_no <=4 then procd_no =procudure_no ;

else if 5 <= procudure_no <=9 then procd_no =5;

else if procudure_no >=10 then procud_no=10;

 

keep record_id indig procedure_no age_grp;

run ;

 

But this time I can only get procd_no=0 when procedure_no is missing and procd_no is missing when procedure_no take other values.

 

Why this can happen? WHat I need to do?

 

Qinghe 

2 REPLIES 2
mohamed_zaki
Barite | Level 11

It is just typo in your code decide is it "procedure_no" or "procudure_no"?

let them all be the same then you will not get the same issue

stat_sas
Ammonite | Level 13

Replace procudure_no with procedure_no. Seems like a spelling mistake. 

 

 

data hosp_proc12a;

merge hosp12 (in=a) procd;

by record_id;

if a;

if procedure_no=. then procedure_no=0;

else if 5 <= procudure_no <=9 then procudure_no =5;

else if procudure_no >=10 then procudure_no=10;

 

keep record_id indig procedure_no age_grp;

run ;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 1488 views
  • 0 likes
  • 3 in conversation