You could use an informat. proc format;
invalue $icdCode "311" - "31199" = "Depression"
other = "Other";
run;
data have;
*Using informat to transform the data in this case, but you could use put(icd1,$icdCode.);
input icd :$icdCode.;
datalines;
31125
32000
25000
311
31199
;;;
run;
data want;
set have;
if icd = "Depression" then hosp =1;
else hosp = 0;
run; With a format, instead of an informat. proc format;
value $icdCode "311" - "31199" = "Depression"
other = "Other";
run;
data have;
length icd $12;
input icd $;
datalines;
31125
32000
25000
311
31199
;;;
run;
data want;
set have;
icd_formated = put(icd,$icdCode.);
if icd_formated = "Depression" then hosp =1;
else hosp = 0;
run;
... View more