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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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.

View solution in original post

20 REPLIES 20
PaigeMiller
Diamond | Level 26

you want to separate the possible values in the IN condition with a comma, not a hyphen as you did

--
Paige Miller
Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

can he use if code in('333.0' :'333.9', '334.0':'334.9') or is the ":" only for ranges of num values?

snoopy369
Barite | Level 11

":" is not only numeric only, but it is *integer* only.

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

Thanks Snoopy369

Reeza
Super User

Are you looking for ranges of codes rather than the two codes alone?

robertrao
Quartz | Level 8

Yes.I am looking for the ranges.

How can i use proc format??Is it possible?

Thnks

PaigeMiller
Diamond | Level 26

Range:

if code>=180 and code<=310.99 then code_Descrip="AIDS";

--
Paige Miller
Reeza
Super User

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.

robertrao
Quartz | Level 8

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

Reeza
Super User

So 180 and 310.99 are not ICD codes? If not, then please disregard my posts.

robertrao
Quartz | Level 8

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;

Reeza
Super User

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;

esjackso
Quartz | Level 8

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

snoopy369
Barite | Level 11

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). 

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!

What is Bayesian Analysis?

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.

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
  • 20 replies
  • 2088 views
  • 6 likes
  • 7 in conversation