I am getting the following error message when I use the code below
Could someone point me in the right direction????
data want;
set have;
if code in('180'-'310.99') then code_Descrip="AIDS";
else if code in('333.0'-'333.9', '334.0'-'334.9') then code_Descrip="FEVER";
else code_Descrip="OTHER";
run;
ERROR 22-322: Syntax error, expecting one of the following: a quoted string,
a numeric constant, a datetime constant, a missing value, iterator, (, ), ','.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 76-322: Syntax error, statement will be ignored.
Thanks
You need to use formats to define the categories and then apply them generally.
proc format;
value $ icdfmt
'180'-'310.99~' = 'AIDS'
'333.0'-'333.9~', '334.0'-'334.9~'='Fever'
other = 'Other';
run;
Are you using Standard ICD9/10 or some other classification system? If so the University of Manitoba has SAS code that provides different classifications.
you want to separate the possible values in the IN condition with a comma, not a hyphen as you did
can he use if code in('333.0' :'333.9', '334.0':'334.9') or is the ":" only for ranges of num values?
":" is not only numeric only, but it is *integer* only.
Thanks Snoopy369
Are you looking for ranges of codes rather than the two codes alone?
Yes.I am looking for the ranges.
How can i use proc format??Is it possible?
Thnks
Range:
if code>=180 and code<=310.99 then code_Descrip="AIDS";
You need to use formats to define the categories and then apply them generally.
proc format;
value $ icdfmt
'180'-'310.99~' = 'AIDS'
'333.0'-'333.9~', '334.0'-'334.9~'='Fever'
other = 'Other';
run;
Are you using Standard ICD9/10 or some other classification system? If so the University of Manitoba has SAS code that provides different classifications.
Hi,
Thanks for the reply,
This is not a standard classification. I was giving it in general.
I have a question in your code..
WHAT IS THE CURLY HYPHEN????WHATS ITS USE???
'180'-'310.99~'
Thanks
So 180 and 310.99 are not ICD codes? If not, then please disregard my posts.
HERE you Go..
These are ICD9 codes
data want;
set have;
if code in('410.0'-414.09) then code_Descrip="HEART DISEASE";
else if code in('250.0'-'250.6', '250.52'-'250.93) then code_Descrip="DIABETES";
else code_Descrip="OTHER";
run;
If this format works for ICD9 then could you explain to me about the ~
proc format;
value $ icdfmt
'410.0'-414.09~' = 'HEART DISEASE'
'250.0'-'250.6~', '250.52'-'250.93~'='DIABETES'
other = 'Other';
run;
A general programming principle I was taught and follow is if you're recoding something check the boundaries, by checking just above, the boundary and just below and a few random values between. This will catch most recoding mistakes.
See the example below and look at the what happens for Diabetes and 250.59 and 250 rather than 250.0
proc format;
value $ icdfmt
'410.0'-'414.9~' = 'HEART DISEASE'
'250.0'-'250.6'='DIABETES'
other = 'Other';
invalue $ icdfmt
'410.0'-'414.9~' = 'HEART DISEASE'
'250.0'-'250.6'='DIABETES'
other = 'Other';
run;
data random;
input code $;
cards;
410.23
410.05
410
410.0
411.1
411.23
413.99
414
414.9
414.99
415.0
415
416
250.0
250
250.99
250.6
250.69
250.99
245.3
;
run;
data check;
set random;
icd_code=code;
format icd_code $icdfmt.;
icd_code2=input(code, $icdfmt.);
run;
Yeah it looks like they want a range of ICD9 codes?
if you are looking for the full set of codes you could test the substr of the first three characters and test that result.
Ive also used format and put statements for more complex health care codes.
EJ
if 180 le input(code,BEST12.) le 310.99 may be the better way to do this. IN with colon doesn't work with decimals (it expands the integers only).
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.