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

Hello,

 

i have dataset with member id along with diagnosis codes, that needs to be bumped against certain icd10 code list.

If there a match found, i just want to output the matched code into new column.

How do i achieve it.

 

below is the sample data.

member dataset

MemberidDiagnosis
8001R413 E039 H900 NA
8002I10 R9431 R4181 Z23 E119
8003G9341 R4189 G4701 I639 NA
8004I2699 R413 E119 E782 E039
8005G4752 F0390 Z6828 R296 R2681 R413 G609 I672 NA
8006I63511 I10 Z6822 G3184 K3184 R4182 R4181 E538 L988 I69354 F0390 E119
8007M79641 R29898 E1142 R41841 I130
8008B348 G309 F0280 J449 NA F0390 R1312 R2689 F419 F329 E039 I10 J209 J329 R5081

 

icd10 dataset;

ICD9_10
R413
R4931
E119
E782
F0390
L988
I130
F329

 

Expected Output;

 

MemberidDiagnosisMatch1Match2Match3
8001R413 E039 H900 NAR413  
8002I10 R9431 R4181 Z23 E119E119  
8003G9341 R4189 G4701 I639 NA   
8004I2699 R413 E119 E782 E039R413E119 
8005G4752 F0390 Z6828 R296 R2681 R413 G609 I672 NAR413  
8006I63511 I10 Z6822 G3184 K3184 R4182 R4181 E538 L988 I69354 F0390 E119E119F0390L988
8007M79641 R29898 E1142 R41841 I130I130  
8008B348 G309 F0280 J449 NA F0390 R1312 R2689 F419 F329 E039 I10 J209 J329 R5081F0390F329 
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data have;
infile cards expandtabs truncover;
input Memberid	Diagnosis & $80.;
cards;
8001	R413 E039 H900 NA
8002	I10 R9431 R4181 Z23 E119
8003	G9341 R4189 G4701 I639 NA
8004	I2699 R413 E119 E782 E039
8005	G4752 F0390 Z6828 R296 R2681 R413 G609 I672 NA
8006	I63511 I10 Z6822 G3184 K3184 R4182 R4181 E538 L988 I69354 F0390 E119
8007	M79641 R29898 E1142 R41841 I130
8008	B348 G309 F0280 J449 NA F0390 R1312 R2689 F419 F329 E039 I10 J209 J329 R5081
;

data icd10;
input ICD9_10 $;
cards;
R413
R4931
E119
E782
F0390
L988
I130
F329
;

data temp;
if _n_=1 then do;
 if 0 then set icd10;
 declare hash h(dataset:'icd10');
 h.definekey('icd9_10');
 h.definedone();
end;
set have;
found=0;
do i=1 to countw(Diagnosis,' ');
  temp=scan(Diagnosis,i,' '); 
  if h.check(key:temp)=0 then do;found=1;var=temp;output;end;
end;
if not found then output;
drop i found temp;
run;

proc transpose data=temp out=want prefix=match;
by memberid Diagnosis;
var var;
run;

View solution in original post

3 REPLIES 3
ballardw
Super User

Is the order of the values in the ICD10 data set important in this problem?

 

I ask because for Memberid = 8004 the match variables are in the order as they appear from left to right in that Diagnosis varible. But for Memberid = 8006 the right most match is reported in the first match position (actually in reverse of their appearance in the diagnosis variable for all three).

 

What is the maximum number of diagnosis codes that appears in any record? Since potentially all of the codes could be matches then you need that many match variables.

 

What do you want to do if the same diagnosis code appears twice or more times for the same memberid? (or have you even looked).

 

Is that an exhaustive list of ICD10 codes or are there more?

 

 

sas33
Calcite | Level 5

Hi ballardw,
No, the order is not important, finding a match is important.
Number of Diagnosis codes is unknown.
I want keep only one diagnosis code that matches, if there are duplicate codes for the same id
ICD10 code list not an exhaustive, it contains more codes about 100.
Ksharp
Super User
data have;
infile cards expandtabs truncover;
input Memberid	Diagnosis & $80.;
cards;
8001	R413 E039 H900 NA
8002	I10 R9431 R4181 Z23 E119
8003	G9341 R4189 G4701 I639 NA
8004	I2699 R413 E119 E782 E039
8005	G4752 F0390 Z6828 R296 R2681 R413 G609 I672 NA
8006	I63511 I10 Z6822 G3184 K3184 R4182 R4181 E538 L988 I69354 F0390 E119
8007	M79641 R29898 E1142 R41841 I130
8008	B348 G309 F0280 J449 NA F0390 R1312 R2689 F419 F329 E039 I10 J209 J329 R5081
;

data icd10;
input ICD9_10 $;
cards;
R413
R4931
E119
E782
F0390
L988
I130
F329
;

data temp;
if _n_=1 then do;
 if 0 then set icd10;
 declare hash h(dataset:'icd10');
 h.definekey('icd9_10');
 h.definedone();
end;
set have;
found=0;
do i=1 to countw(Diagnosis,' ');
  temp=scan(Diagnosis,i,' '); 
  if h.check(key:temp)=0 then do;found=1;var=temp;output;end;
end;
if not found then output;
drop i found temp;
run;

proc transpose data=temp out=want prefix=match;
by memberid Diagnosis;
var var;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 494 views
  • 1 like
  • 3 in conversation