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!

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