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

Hello,

I have a variable with ICD codes. I want everything of the left of the decimal. But some cells have multiple codes in a row.

 

ICD_Code ICD_Code1
C18.9 C18
C15.9 C15
Z80.3 Z80
Z12.11, Z12.12  
Z85.46 Z85
Z85.528 Z85
C65.9, C66.9  

 

My code was as following:

if  ICD_Code1 in ("C85","C50",   ~~ a lot more codes~~ ) then Cancer=1;

 

I also tried with scan and substr, but I don't know how to do it when there are many values separated by commas.

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
kelxxx
Quartz | Level 8
data _null_;
x="C60.182, C29.4, C30.1";
y=prxchange('s/\.\d+/ /',-1, x);
put y=;
run;

>>>LOG: y=C60, C29, C30 

data want;
set have;
y=prxchange('s/\.\d+/ /',-1, ICD_Code);
run;

Hope can help you

View solution in original post

2 REPLIES 2
kelxxx
Quartz | Level 8
data _null_;
x="C60.182, C29.4, C30.1";
y=prxchange('s/\.\d+/ /',-1, x);
put y=;
run;

>>>LOG: y=C60, C29, C30 

data want;
set have;
y=prxchange('s/\.\d+/ /',-1, ICD_Code);
run;

Hope can help you

Xinxin
Obsidian | Level 7
Thank you...that worked and I learnt something new!!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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