BookmarkSubscribeRSS Feed
manya92
Fluorite | Level 6

Hi. I need to look for the given diagnostic codes which might have multiple categories within it in my cohor. I want to assign a macro variable with all the codes so I can write :

Data want ;

                Set have ;

                Where code index or substr &macro. ;

Run ;

Where &macro. Is the macro variable containing the codeslist.

Codelist  . These are ICD9 codes and can have subcategories like 001 – 001.1, 001.2 etc.

I want to use index or substring function

001

002

003

004

005

006

007

008

009

010

011

012

013

014

015

016

017

018

020

021

022

023

024

025

026

027

030

031

032

033

034

035

036

037

038

039

040

041

042

045

046

047

048

049

050

051

052

053

054

055

056

057

060

061

062

063

064

065

066

070

071

072

073

074

075

076

077

078

079

080

081

082

083

084

085

086

087

088

090

091

092

093

094

095

096

097

098

099

100

101

102

103

104

 

2 REPLIES 2
PaigeMiller
Diamond | Level 26

I need to look for the given diagnostic codes which might have multiple categories within it in my cohor. I want to assign a macro variable with all the codes so I can write :

Data want ;

                Set have ;

                Where code index or substr &macro. ;

Run ;

Where &macro. Is the macro variable containing the codeslist.

Codelist  . These are ICD9 codes and can have subcategories like 001 – 001.1, 001.2 etc.

I want to use index or substring function

 

This is really unclear to me, in particular, I don't really understand the part in red. You need to provide a lot more detail about what you are trying to do and what you want as the result.

--
Paige Miller
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Quite simply don't.  You will come across a whole realm of problems, extra coding, code falling over etc if you do.  Put data in datasets - this is what they are for.  Then you can query them etc.:

Assumes I have:

001

002

003

 

In a dataset called list:

proc sql;
  create table want as
  select * 
  from   have
  where code in (select code from list);
quit;

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
  • 2 replies
  • 229 views
  • 0 likes
  • 3 in conversation