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

Hi All,

I have a reference table like this:

ICD9      Suicide        Depression     Homicide     Anxiety

290         0                 0                      0                   0

291         0                 0                      0                   0

292         0                 0                      0                   0

V171       0                 0                      0                   0

294         0                 0                      0                   0

V143      0                 1                      0                   0

296         0                 0                      0                   0

296         0                 0                      0                   1

........

Now I want to create five macro variables.-----&ICD, &Suicide, &Depression, &Homicide, &Anxiety, and use values under ICD9 to populate these macro variables.

The logic is like this (the codes are probably not correct):

call symput ('ICD', ICD9);

if Suicide=1 then call symput ('Suicide', ICD9);

if Depression=1 then call symput ('Depression', ICD9);

if Homicide=1 then call symput ('Homicide', ICD9);

if Anxiety=1 then call symput ('Anxiety', ICD9);

Then I want to use medical claim table to flag those claim lines with ICD9 codes for those four conditions.

Something like this:

Data claim_output;

set claim_input;

where ICD9 in (&Suicide);

run;

What should be the correct codes for the whole process?

I appreciate any input!!

Cindy

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

If your data isn't massive over tens of millions I'd probably use a SQL subquery instead:

proc sql;

     create table claim_output as

     select * from claim_input

     where icd9 in (select distinct icd9 from ref where suicide=1);

quit;

View solution in original post

3 REPLIES 3
Reeza
Super User

If your data isn't massive over tens of millions I'd probably use a SQL subquery instead:

proc sql;

     create table claim_output as

     select * from claim_input

     where icd9 in (select distinct icd9 from ref where suicide=1);

quit;

cindyforest7
Calcite | Level 5

Thank you Reeza!

Just curious, if I want to use macro variables to do this, what the codes look like?

Thanks again!

Reeza
Super User

Still using a proc sql step to create your macro variables such that it completes your SAS code properly. Because they're strings they also need to have the correct quotes and commas are optional. Ie you want suicide to resolve to "V143", "128".


This is an example below:


       Proc SQL noprint;
         select quote(strip(icd9)) into :suicide separated by ','
          from reference_table

          where suicide=1;
          quit;
           run;
        %put NOTE: Suicide=&suicide;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 872 views
  • 3 likes
  • 2 in conversation