In a question like this, always present the logs first.
If possible, a program will also help us give you better advice.
Please post the complete (code and messages) log from that step. Use this button to post the log:
@alramjoh wrote:
I keep getting an error message stating the var in the rename has not been referenced.
How do I reference it?
First thing: this message is not an error. It is only a note.
Typically this involves using the variable name somewhere but the variable named does not have any values assigned.
My most frequent cause is spelling error for a variable in the data set but not using the variable in calculations.
You can run the example code below as you should have a SASHELP.CLASS data set. This code is intended to change the label of an existing variable, height, but was misspelled. So since HHEIGHT never has a value assigned SAS generates that note. If you look at the created Example data set you will see a variable named Hheight as it was created and all of the value will be missing.
3119 data example; 3120 set sashelp.class; 3121 label hheight='Child weight at enrollment'; 3122 run; NOTE: Variable hheight is uninitialized. NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: The data set WORK.EXAMPLE has 19 observations and 5 variables. NOTE: DATA statement used (Total process time):
Here is much more destructive example. Here the intent was the change the height from inches to centimeters as units:
3123 data example; 3124 set sashelp.class; 3125 height = hheight *25.4; 3126 run; NOTE: Variable hheight is uninitialized.
This is one of the reasons not use the same output data set name as the input name when recoding existing variables such as:
Data existing; set existing; <code with nonfatal error> ; run;
Since hheight did not exist the missing value resulting from multiplying the missing value has replaced all of the existing height measurements. Which means you need to go back and rebuild the original data set.
here is what I have
I dont believe I misspelled anything. I just simply trying to rename my variables this way and getting stuck with this warning message
We need to see the ENTIRE log for this DATA step or PROC, that is, do not choose parts to show us and then not show us other parts. Show us every single line of the LOG for this DATA step or PROC. Copy the log as text (not a screen capture) and then follow the instructions presented by @Kurt_Bremser .
PROC IMPORT DATAFILE=REFFILE DBMS=DLM OUT=HW1.hepa1; DELIMITER=''; GETNAMES=NO; GUESSINGROWS=MAX; RUN; *The previous step indicates that I imported data; data modified; set hw1.hepa1; rename var1= class var2= age var3= sex var4= steriod var5= antivirals var6= fatigue var7= malaise var8= anorexia var9= liverbig var10= liverfirm var11= spleenpalpable var12= spiders var13= ascites var14= varices var15= bilirubin var16= alkphosphate var17= sgot var18= albumin var19= protime var20= histology; run;
Thanks, but this is not the LOG, this is the program. We need to see the ENTIRE log for this section of code, every single line.
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 87         PROC IMPORT DATAFILE=REFFILE
 88         DBMS=CSV
 89         OUT=HW1.glass;
 90         GETNAMES=YES;
 91         RUN;
 
 NOTE: Import cancelled.  Output dataset HW1.GLASS already exists.  Specify REPLACE option to overwrite it.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              247.71k
       OS Memory           23456.00k
       Timestamp           09/02/2021 02:31:16 PM
       Step Count                        24  Switch Count  0
       Page Faults                       0
       Page Reclaims                     120
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 92         
 93         *The above data step shows that I imported data;
 94         
 95         
 96         FILENAME REFFILE '/home/u59197232/mylib/bupa.xlsx';
 97         
 
 
 98         PROC IMPORT DATAFILE=REFFILE
 99         DBMS=XLSX
 100        OUT=HW1.bupa;
 101        GETNAMES=YES;
 102        *The above data step shows I imported data;
 103        
 104        FILENAME REFFILE '/home/u59197232/dataset1/hepa1.sas7bdat';
 105        
 
 NOTE: Import cancelled.  Output dataset HW1.BUPA already exists.  Specify REPLACE option to overwrite it.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              686.71k
       OS Memory           23952.00k
       Timestamp           09/02/2021 02:31:16 PM
       Step Count                        25  Switch Count  1
       Page Faults                       0
       Page Reclaims                     178
       Page Swaps                        0
       Voluntary Context Switches        6
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 
 
 106        PROC IMPORT DATAFILE=REFFILE
 107        DBMS=DLM
 108        OUT=HW1.hepa1;
 109        DELIMITER='';
 110        GETNAMES=NO;
 111        GUESSINGROWS=MAX;
 112        RUN;
 
 NOTE: Import cancelled.  Output dataset HW1.HEPA1 already exists.  Specify REPLACE option to overwrite it.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              197.93k
       OS Memory           23456.00k
       Timestamp           09/02/2021 02:31:16 PM
       Step Count                        26  Switch Count  0
       Page Faults                       0
       Page Reclaims                     15
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 113        
 114        *The previous step indicates that I imported data;
 
 
 115        data modified;
 116        set hw1.hepa1;
 117        rename var1= class
 118        var2= age
 119        var3= sex
 120        var4= steriod
 121        var5= antivirals
 122        var6= fatigue
 123        var7= malaise
 124        var8= anorexia
 125        var9= liverbig
 126        var10= liverfirm
 127        var11= spleenpalpable
 128        var12= spiders
 129        var13= ascites
 130        var14= varices
 131        var15= bilirubin
 132        var16= alkphosphate
 133        var17= sgot
 134        var18= albumin
 135        var19= protime
 136        var20= histology;
 137        run;
 
 WARNING: The variable var1 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var2 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var3 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var4 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var5 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var6 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var7 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var8 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var9 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var10 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var11 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var12 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var13 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var14 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var15 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var16 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var17 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var18 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var19 in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable var20 in the DROP, KEEP, or RENAME list has never been referenced.
 NOTE: There were 154 observations read from the data set HW1.HEPA1.
 NOTE: The data set WORK.MODIFIED has 154 observations and 20 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              974.21k
       OS Memory           24488.00k
       Timestamp           09/02/2021 02:31:16 PM
       Step Count                        27  Switch Count  2
       Page Faults                       0
       Page Reclaims                     220
       Page Swaps                        0
       Voluntary Context Switches        16
       Involuntary Context Switches      0
       Block Input Operations            288
       Block Output Operations           272
       
 
 138        
 139        libname HW1 '/home/u59197232/dataset1';
 NOTE: Libref HW1 was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /home/u59197232/dataset1
 140        proc import datafile='/home/u59197232/dataset1/bupa.sas7bdat'
 141        dbms=xlsx
 142        out=hw1.bupa;
 143        getnames=yes;
 144        run;
 
 NOTE: Import cancelled.  Output dataset HW1.BUPA already exists.  Specify REPLACE option to overwrite it.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              686.71k
       OS Memory           24464.00k
       Timestamp           09/02/2021 02:31:16 PM
       Step Count                        28  Switch Count  0
       Page Faults                       0
       Page Reclaims                     138
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 145        *The above is a read in for bupa;
 146        
 147        
 148        libname HW1 '/home/u59197232/dataset1';
 NOTE: Libref HW1 was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /home/u59197232/dataset1
 
 
 149        proc import datafile= '/home/u59197232/dataset1/glass.sas7bdat'
 150        dbms=xlsx
 151        out=hw1.glass;
 152        getnames=yes;
 153        run;
 
 NOTE: Import cancelled.  Output dataset HW1.GLASS already exists.  Specify REPLACE option to overwrite it.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              686.71k
       OS Memory           24464.00k
       Timestamp           09/02/2021 02:31:16 PM
       Step Count                        29  Switch Count  0
       Page Faults                       0
       Page Reclaims                     138
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 154        *The above is a read in for glass;
 155        
 156        libname HW1 '/home/u59197232/dataset1';
 NOTE: Libref HW1 was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /home/u59197232/dataset1
 
 
 157        proc import datafile= '/home/u59197232/dataset1/hepa1.sas7bdat'
 158        dbms= dlm
 159        out=hw1.hepa1;
 160        getnames=no;
 161        run;
 
 NOTE: Import cancelled.  Output dataset HW1.HEPA1 already exists.  Specify REPLACE option to overwrite it.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              193.93k
       OS Memory           23968.00k
       Timestamp           09/02/2021 02:31:16 PM
       Step Count                        30  Switch Count  0
       Page Faults                       0
       Page Reclaims                     14
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 162        
 163        *The above is a read in for hepa;
 164        
 
 
 165        proc print data= '/home/u59197232/dataset1/glass.sas7bdat' ;
 166        run;
 
 NOTE: There were 213 observations read from the data set /home/u59197232/dataset1/glass.sas7bdat.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.37 seconds
       user cpu time       0.37 seconds
       system cpu time     0.00 seconds
       memory              1282.59k
       OS Memory           24996.00k
       Timestamp           09/02/2021 02:31:17 PM
       Step Count                        31  Switch Count  1
       Page Faults                       0
       Page Reclaims                     471
       Page Swaps                        0
       Voluntary Context Switches        11
       Involuntary Context Switches      2
       Block Input Operations            288
       Block Output Operations           152
       
 
 167        *The above shows the proc print step for the glass file;
 168        
 169        proc print data= '/home/u59197232/dataset1/bupa.sas7bdat';
 170        run;
 
 NOTE: There were 344 observations read from the data set /home/u59197232/dataset1/bupa.sas7bdat.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.40 seconds
       user cpu time       0.40 seconds
       system cpu time     0.00 seconds
       memory              723.12k
       OS Memory           24996.00k
       Timestamp           09/02/2021 02:31:17 PM
       Step Count                        32  Switch Count  1
       Page Faults                       0
       Page Reclaims                     82
       Page Swaps                        0
       Voluntary Context Switches        12
       Involuntary Context Switches      0
       Block Input Operations            288
       Block Output Operations           176
       
 
 171        
 172        *The above shows the proc print step for the bupa file;
 173        
 174        proc print data= '/home/u59197232/dataset1/hepa1.sas7bdat';
 175        run;
 
 NOTE: There were 154 observations read from the data set /home/u59197232/dataset1/hepa1.sas7bdat.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.46 seconds
       user cpu time       0.47 seconds
       system cpu time     0.00 seconds
       memory              753.00k
       OS Memory           24996.00k
       Timestamp           09/02/2021 02:31:17 PM
       Step Count                        33  Switch Count  1
       Page Faults                       0
       Page Reclaims                     76
       Page Swaps                        0
       Voluntary Context Switches        6
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           160
       
 
 176        
 177        
 178        
 179        
 180        
 181        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 191        
					
				
			
			
				
			
			
			
			
			
			
			
		
NOTE: Import cancelled. Output dataset HW1.HEPA1 already exists. Specify REPLACE option to overwrite it.
So while you think you are importing a certain file, you have not actually performed an import of that file. How to fix this? It is stated clearly in the above message.
WARNING: The variable var1 in the DROP, KEEP, or RENAME list has never been referenced.
There is no such variable named VAR1 in the data set you are using named HW1.HEPA1. So maybe fixing the import problem above fixes this problem too, or maybe not. In any event, you have to use names of variables that actually exist in the data set when you rename.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.