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

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:

134Pulmonary embolism                                                 
135Major chest & respiratory trauma                                   
136Respiratory malignancy                                             
137Major respiratory infections & inflammations                       
138Bronchiolitis & RSV pneumonia                                      
139Other pneumonia                                                    
140Chronic obstructive pulmonary disease                              
141Asthma                                                             
142Interstitial & alveolar lung diseases                              
143Other respiratory diagnoses except signs, symptoms & minor diagnoses
144Respiratory signs, symptoms & minor diagnoses                      
160Major cardiothoracic repair of heart anomaly                       
161Cardiac defibrillator & heart assist implant                       
162Cardiac 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?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

4 REPLIES 4
ballardw
Super User

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.

bikash
Calcite | Level 5

Thanks Ballardw.

Ksharp
Super User

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.

bikash
Calcite | Level 5

Thanks Xia. Those skills are too advanced for me right now. I will use format for this time.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1565 views
  • 1 like
  • 3 in conversation