I don't understand why when I'm running this code
length ICD_cat 3. ICD_other $ 1 ICD_cat10 2. DIAGNOSIS_GROUP $ 50 /*PEPPER_DX_GROUP $ 50 */
provst $ 2 benest $ 2 clm_yr 4. fiscal_yr 4. ICD_cat_num 3.;
ICD_cat=substr(clm_prncpal_dgns_cd,1,3);
ICD_cat_num=compress(ICD_cat,'','A');
ICD_other=substr(clm_prncpal_dgns_cd,1,1);
ICD_cat10=substr(clm_prncpal_dgns_cd,2,2);
clm_yr=2015;
if month(datepart(CLM_FROM_DT)) < 10 then fiscal_yr=2015;
else fiscal_yr=(clm_yr + 1);
/*Categorizing ICD-9 diagnosis codes (numeric) into diagnosis groups*/
if clm_prncpal_dgns_cd in ('3310') then do; DIAGNOSIS_GROUP = 'Alzheimers'; end;
else if fiscal_yr=2015 and ICD_other = 'V' then do; DIAGNOSIS_GROUP = 'Factors Influence Health'; end;
else if fiscal_yr=2015 and ICD_other = 'E' then do; DIAGNOSIS_GROUP = 'External Causes'; end;
else if fiscal_yr=2015 and 001<=ICD_cat_num<=139 then do; DIAGNOSIS_GROUP = 'Infection'; end;
else if fiscal_yr=2015 and 140<=ICD_cat_num<=239 then do; DIAGNOSIS_GROUP = 'Cancer'; end;
else if fiscal_yr=2015 and 240<=ICD_cat_num<=279 then do; DIAGNOSIS_GROUP = 'Endocrine'; end;
else if fiscal_yr=2015 and 280<=ICD_cat_num<=289 then do; DIAGNOSIS_GROUP = 'Blood'; end;
else if fiscal_yr=2015 and 290<=ICD_cat_num<=319 then do; DIAGNOSIS_GROUP = 'Mental'; end;
else if fiscal_yr=2015 and 320<=ICD_cat_num<=389 then do; DIAGNOSIS_GROUP = 'Nervous System'; end;
else if fiscal_yr=2015 and 390<=ICD_cat_num<=459 then do; DIAGNOSIS_GROUP = 'Circulatory'; end;
else if fiscal_yr=2015 and 460<=ICD_cat_num<=519 then do; DIAGNOSIS_GROUP = 'Respiratory'; end;
else if fiscal_yr=2015 and 520<=ICD_cat_num<=579 then do; DIAGNOSIS_GROUP = 'Digestive'; end;
else if fiscal_yr=2015 and 580<=ICD_cat_num<=629 then do; DIAGNOSIS_GROUP = 'Genitourinary'; end;
else if fiscal_yr=2015 and 630<=ICD_cat_num<=679 then do; DIAGNOSIS_GROUP = 'Childbirth/Pregnancy'; end;
else if fiscal_yr=2015 and 680<=ICD_cat_num<=709 then do; DIAGNOSIS_GROUP = 'Skin'; end;
else if fiscal_yr=2015 and 710<=ICD_cat_num<=739 then do; DIAGNOSIS_GROUP = 'Musculoskeletal'; end;
else if fiscal_yr=2015 and 740<=ICD_cat_num<=759 then do; DIAGNOSIS_GROUP = 'Congenital Anomalies'; end;
else if fiscal_yr=2015 and 760<=ICD_cat_num<=779 then do; DIAGNOSIS_GROUP = 'Prenatal'; end;
else if fiscal_yr=2015 and 780<=ICD_cat_num<=799 then do; DIAGNOSIS_GROUP = 'Ill-Defined'; end;
else if fiscal_yr=2015 and 800<=ICD_cat_num<=999 then do; DIAGNOSIS_GROUP = 'Injury/Poisoning'; end;
/*Categorizing ICD-10 diagnosis codes (alphanumeric) into diagnosis groups. ICD-10 became effective October 1, 2015 (FY2016). See http://www.icd10data.com/ICD10CM/Codes*/
else if fiscal_yr=2016 and (ICD_other='A' or ICD_other='B') then do; DIAGNOSIS_GROUP = 'Infection'; end;
else if fiscal_yr=2016 and (ICD_other='C' or (ICD_other = 'D' and 00<=ICD_cat10<=49) or (ICD_other='D' and (substr(CLM_PRNCPAL_DGNS_CD,2,2))='3A')) then do; DIAGNOSIS_GROUP='Cancer'; end;
else if fiscal_yr=2016 and (ICD_other='D' and 50<=ICD_cat10<=89) then do; DIAGNOSIS_GROUP = 'Blood'; end;
else if fiscal_yr=2016 and (ICD_other='E' and (00<=ICD_cat10<=89)) then do; DIAGNOSIS_GROUP = 'Endocrine'; end;
else if fiscal_yr=2016 and ICD_other='F' then do; DIAGNOSIS_GROUP = 'Mental'; end;
else if fiscal_yr=2016 and ICD_other='G' then do; DIAGNOSIS_GROUP = 'Nervous System'; end;
else if fiscal_yr=2016 and (ICD_other='H' and 00<=ICD_cat10<=59) then do; DIAGNOSIS_GROUP = 'Eye and Adnexa'; end;
else if fiscal_yr=2016 and (ICD_other='H' and 60<=ICD_cat10<=95) then do; DIAGNOSIS_GROUP = 'Ear and Mastoid Process'; end;
else if fiscal_yr=2016 and ICD_other='I' then do; DIAGNOSIS_GROUP = 'Circulatory'; end;
else if fiscal_yr=2016 and ICD_other='J' then do; DIAGNOSIS_GROUP = 'Respiratory'; end;
else if fiscal_yr=2016 and ICD_other='K' then do; DIAGNOSIS_GROUP = 'Digestive'; end;
else if fiscal_yr=2016 and ICD_other='L' then do; DIAGNOSIS_GROUP = 'Skin'; end;
else if fiscal_yr=2016 and ICD_other='M' then do; DIAGNOSIS_GROUP = 'Musculoskeletal'; end;
else if fiscal_yr=2016 and ICD_other='N' then do; DIAGNOSIS_GROUP = 'Genitourinary'; end;
else if fiscal_yr=2016 and ICD_other='O' then do; DIAGNOSIS_GROUP = 'Childbirth/Pregnancy'; end;
else if fiscal_yr=2016 and ICD_other='P' then do; DIAGNOSIS_GROUP = 'Prenatal'; end;
else if fiscal_yr=2016 and ICD_other='Q' then do; DIAGNOSIS_GROUP = 'Congenital Anomalies'; end;
else if fiscal_yr=2016 and ICD_other='R' then DIAGNOSIS_GROUP = 'Ill-Defined';
else if fiscal_yr=2016 and ICD_other in ('S','T') then do; DIAGNOSIS_GROUP = 'Injury/Poisoning'; end;
else if fiscal_yr=2016 and (ICD_other='V' or ICD_other='Y') then do; DIAGNOSIS_GROUP = 'External Causes'; end;
else if fiscal_yr=2016 and ICD_other='Z' then do; DIAGNOSIS_GROUP='Factors Influence Health'; end;
else if ICD_cat = ' ' then do; DIAGNOSIS_GROUP = 'Missing'; end;
I get this note/error:
NOTE: Invalid numeric data, 'G20' , at line 81 column 17.
Any suggestions on how I can address this problem? I tried "if/then" statements prior to these "if/then do" statements, but both approaches yield the same SAS note/error. (I'm using SAS 9.4)
Thanks
This
ICD_cat=substr(clm_prncpal_dgns_cd,1,3);
is the culprit.
By assigning a length of 3. (instead of $3.) to ICD_cat, you defined it numeric. As clm_prncpal_dgns_cd contains 'G20', SAS then fails when it tries to convert the result of the substr to numeric.
Make the length of ICD_cat in the length statement $3, and you should be fine.
Look at line 81 of your log. You're doing something there that assumes that the contents of CLM_PRNCPAL_DGNS_CD are numeric.
Probably an input() function or a mathematical operation.
Not read the whole things, but from your error (comments between ^):
length ICD_cat 3. ICD_other $ 1 ICD_cat10 2. DIAGNOSIS_GROUP $ 50 /*PEPPER_DX_GROUP $ 50 */
provst $ 2 benest $ 2 clm_yr 4. fiscal_yr 4. ICD_cat_num 3.;
^ defined as num ^
ICD_cat_num=compress(ICD_cat,'','A');
^ the above returns a string, icd_cat and the letter 'A', as that is not a number you get the error ^
It would be easier if you would tell us which line of the program corresponds to line 81 that the log is referencing.
At any rate, your LENGTH statement makes ID_CAT numeric. That is probably wrong. Change the LENGTH statement to make ID_CAT character and that should handle the problem.
This
ICD_cat=substr(clm_prncpal_dgns_cd,1,3);
is the culprit.
By assigning a length of 3. (instead of $3.) to ICD_cat, you defined it numeric. As clm_prncpal_dgns_cd contains 'G20', SAS then fails when it tries to convert the result of the substr to numeric.
Make the length of ICD_cat in the length statement $3, and you should be fine.
Issue solved. Thank you all for your assistance.
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.
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.