I have variable named DRG (Diagnosis Related Group) in my SAS dataset. DRG can be any where between 001 to 989 for diagnosis which patient are treated. I have label of those DRG 001 to 989 in excel like this:
134 | Pulmonary embolism |
135 | Major chest & respiratory trauma |
136 | Respiratory malignancy |
137 | Major respiratory infections & inflammations |
138 | Bronchiolitis & RSV pneumonia |
139 | Other pneumonia |
140 | Chronic obstructive pulmonary disease |
141 | Asthma |
142 | Interstitial & alveolar lung diseases |
143 | Other respiratory diagnoses except signs, symptoms & minor diagnoses |
144 | Respiratory signs, symptoms & minor diagnoses |
160 | Major cardiothoracic repair of heart anomaly |
161 | Cardiac defibrillator & heart assist implant |
162 | Cardiac valve procedures w cardiac catheterization |
How can I label DRG directly from excel? I can copy and paste it in SAS and label it but is there any way to add label to DRG directly from excel?
Are codes and the text in separate columns? I think the Excel approach is VLOOKUp.
Better would be to create a SAS format and then export the formatted value.
Proc format;
value DRG /* assumes DRG is numeric*/
134 ='Pulmonary embolism'
135 ='Major chest & respiratory trauma'
136 ='Respiratory malignancy'
137 ='Major respiratory infections & inflammations'
138 ='Bronchiolitis & RSV pneumonia'
/* continue with the rest Or learn the utility of a CNTLIN dataset*/
;
run;
And then associate the format with the variable when writing the DRG variable out and you don't need to do anything else like a look up in Excel.
Are codes and the text in separate columns? I think the Excel approach is VLOOKUp.
Better would be to create a SAS format and then export the formatted value.
Proc format;
value DRG /* assumes DRG is numeric*/
134 ='Pulmonary embolism'
135 ='Major chest & respiratory trauma'
136 ='Respiratory malignancy'
137 ='Major respiratory infections & inflammations'
138 ='Bronchiolitis & RSV pneumonia'
/* continue with the rest Or learn the utility of a CNTLIN dataset*/
;
run;
And then associate the format with the variable when writing the DRG variable out and you don't need to do anything else like a look up in Excel.
Thanks Ballardw.
use proc import to import that excel file and use some match skills like : Hash Table ,SQL, Merge, proc format ......... to bring those labels back into SAS dataset.
Thanks Xia. Those skills are too advanced for me right now. I will use format for this time.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.