Help using Base SAS procedures

Efficient way to Label based on variable value in Excel

Accepted Solution Solved
Reply
Contributor
Posts: 21
Accepted Solution

Efficient way to Label based on variable value in Excel

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?


Accepted Solutions
Solution
‎01-28-2015 05:06 PM
Super User
Posts: 10,466

Re: Efficient way to Label based on variable value 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.

View solution in original post


All Replies
Solution
‎01-28-2015 05:06 PM
Super User
Posts: 10,466

Re: Efficient way to Label based on variable value 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.

Contributor
Posts: 21

Re: Efficient way to Label based on variable value in Excel

Thanks Ballardw.

Super User
Posts: 9,662

Re: Efficient way to Label based on variable value in Excel

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.

Contributor
Posts: 21

Re: Efficient way to Label based on variable value in Excel

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

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 226 views
  • 0 likes
  • 3 in conversation