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

I have a column called ICD10 and i need to put new values in CODCd based on the info in ICD10

 

"Create values based on ICD10 as:
1 (I25.XX), 2 (I50.XX), 3 (I63.XX), and 4 (Other)"

 

 

this is what I have 

If MISSING(ICD10) = 1 then CODCd = ".";
Else if ICD10 = 125 -< 126 then CODCd = 1;
Else If ICD10 = 150 -< 151 then CODCd = 2;
Else If ICD10 = 163 -< 164 then CODCd = 3;
Else CodCd = 4;

but i keep on getting a syntax error. 

 

Is there a simpler way of doing this?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

ICD10 code are character strings (ICD9 codes should be characters strings also).

So use the : modifier on your comparison operators to do truncated comparisons.

if missing(ICD10) then CODCd = .;
else if ICD10 =: 'I25' then CODCd = 1;
else if ICD10 =: 'I50' then CODCd = 2;
else if ICD10 =: 'I63' then CODCd = 3;
else CodCd = 4;

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Your syntax error (you should really show us the log when error(s) appear) is most likely because on the first line of code, you set CODCd to be character; and then on later lines you set it numeric. It can't be both, you have to pick one or the other. I would make the first line

 

If MISSING(ICD10) = 1 then CODCd = .;

and now they're all numeric.

 

As far as ICD10 codes are concerned, I think this has all been worked out many times here in the forums and elsewhere, and you shouldn't really have to write your own code ... but as I don't personally get involved in work that uses medical codes, I can't help further, but your favorite internet search engine probably can.

 

Lastly, I urge you to look carefully at the codes involved, where you say

 

"Create values based on ICD10 as:
1 (I25.XX), 2 (I50.XX), 3 (I63.XX), and 4 (Other)"

 

look very very carefully ... the character immediately to the left of 25.XX is not a 1, so when you are testing if something equals 125, I don't think there are ICD10 codes that begin with 125. If it was a 1, then simple rounding down of the decimal to the nearest integer less than or equal to the 125.xx would be dandy, and simple to program ... but it's not a 1.

--
Paige Miller
Tom
Super User Tom
Super User

ICD10 code are character strings (ICD9 codes should be characters strings also).

So use the : modifier on your comparison operators to do truncated comparisons.

if missing(ICD10) then CODCd = .;
else if ICD10 =: 'I25' then CODCd = 1;
else if ICD10 =: 'I50' then CODCd = 2;
else if ICD10 =: 'I63' then CODCd = 3;
else CodCd = 4;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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