Hi chuakp, Below is one style of coding. Coding the various possible values of diagnosis codes saves the need for using the upper, lower or proper case functions. If you have to add codes or change the output locations of codes, it is easier to manipulate the proc format than the data step code. The notfound and error statements are redundant. I added them just to show you what is possible. If a new 'type' is ever added to SASHELP.CARS, the notfound dataset would contain any rows with the new type. proc format; value $diagx 'SEDAN','Sedan','sedan' = 1 'SUV','Suv','suv' = 2 'SPORTS','Sports','sports' = 3 'WAGON','Wagon','wagon' = 4 'TRUCK','Truck','truck' = 5 'HYBRID','Hybrid','hybrid' = 6 OTHER = 7 run;; data want1 want2 want3 want4 want5 want6 notfound error; set sashelp.cars; if put(type,$diagx.) = 1 then output want1; else if put(type,$diagx.) = 2 then output want2; else if put(type,$diagx.) = 3 then output want3; else if put(type,$diagx.) = 4 then output want4; else if put(type,$diagx.) = 5 then output want5; else if put(type,$diagx.) = 6 then output want6; else if put(type,$diagx.) = 7 then output notfound; else output error; run; NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column). 354:5 355:10 356:10 357:10 358:10 359:10 360:10 NOTE: There were 428 observations read from the data set SASHELP.CARS. NOTE: The data set WORK.WANT1 has 262 observations and 15 variables. NOTE: The data set WORK.WANT2 has 60 observations and 15 variables. NOTE: The data set WORK.WANT3 has 49 observations and 15 variables. NOTE: The data set WORK.WANT4 has 30 observations and 15 variables. NOTE: The data set WORK.WANT5 has 24 observations and 15 variables. NOTE: The data set WORK.WANT6 has 3 observations and 15 variables. NOTE: The data set WORK.NOTFOUND has 0 observations and 15 variables. NOTE: The data set WORK.ERROR has 0 observations and 15 variables. NOTE: DATA statement used (Total process time): real time 1.21 seconds cpu time 0.20 seconds
... View more