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

Hello,

 

I have two variables BEGIN and END in a dataset A, and Dataset B has a variable called DIAGNOSIS CODE. I would like to see if any value in the diagnosis code variable falls in the range between Begin and End variable.

 

Example: 

 

Dataset A(Have)                                                           Dataset B(Have)                                              Dataset C(want)

 

Begin                  End                                                 Diagnosis code                                                       Flag

1                            3                                                          5                                                                        2                  

 7                           10                                                        2                                                                        17

16                          24                                                        11

                                                                                          17

Thanks for all your help!

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

Like this?

proc sql; select CODE as FLAG from HAVE1, HAVE2 where CODE between BEGIN and END;

 

View solution in original post

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

Like this?

proc sql; select CODE as FLAG from HAVE1, HAVE2 where CODE between BEGIN and END;

 

DivyaGadde
Fluorite | Level 6

Thanks very much!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1377 views
  • 0 likes
  • 2 in conversation