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

I'm trying to rename variables and then drop the originally named variables and keep the newly named ones. 

I have read this, this and this and cannot figure it out. 

DATA meta.data_01;
	SET meta.data_01;
	
	(RENAME =	(
				Map_Alpha1_V1=BH_ApoA1_V1
				Map_Alpha1_V2=BH_ApoA1_V2
				Map_Alpha1_V3=BH_ApoA1_V3
				Map_Alpha2_V1=BH_ApoA2_V1
				Map_Alpha2_V2=BH_ApoA2_V2
				Map_Alpha2_V3=BH_ApoA2_V3
				Map_Alpha3_V1=BH_ApoA3_V1
				Map_Alpha3_V2=BH_ApoA3_V2
				Map_Alpha3_V3=BH_ApoA3_V3
				Map_Alpha4_V1=BH_ApoA4_V1
				Map_Alpha4_V2=BH_ApoA4_V2
				Map_Alpha4_V3=BH_ApoA4_V3
				Map_PreB1_V1=BH_PreBeta_1_V1
				Map_PreB1_V2=BH_PreBeta_1_V2
				Map_PreB1_V3=BH_PreBeta_1_V3
				);


	DROP = 		(              
		 		Map:
               	);
RUN;

Log: 


1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 DATA meta.data_01;
70 SET meta.data_01;
71
72 (RENAME =(
_
180
ERROR 180-322: Statement is not valid or it is used out of proper order.

73 Map_Alpha1_V1=BH_ApoA1_V1
74 Map_Alpha1_V2=BH_ApoA1_V2
75 Map_Alpha1_V3=BH_ApoA1_V3
76 Map_Alpha2_V1=BH_ApoA2_V1
77 Map_Alpha2_V2=BH_ApoA2_V2
78 Map_Alpha2_V3=BH_ApoA2_V3
79 Map_Alpha3_V1=BH_ApoA3_V1
80 Map_Alpha3_V2=BH_ApoA3_V2
81 Map_Alpha3_V3=BH_ApoA3_V3
82 Map_Alpha4_V1=BH_ApoA4_V1
83 Map_Alpha4_V2=BH_ApoA4_V2
84 Map_Alpha4_V3=BH_ApoA4_V3
85 Map_PreB1_V1=BH_PreBeta_1_V1
86 Map_PreB1_V2=BH_PreBeta_1_V2
87 Map_PreB1_V3=BH_PreBeta_1_V3
88 );
89
90
91 DROP = (
92 Map:
_
388
200
76
ERROR 388-185: Expecting an arithmetic operator.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR 76-322: Syntax error, statement will be ignored.

93 );
94 RUN;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set META.DATA_01 may be incomplete. When this step was stopped there were 0 observations and 179 variables.
WARNING: Data set META.DATA_01 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 1431.56k
OS Memory 33204.00k
Timestamp 11/19/2021 08:46:47 PM
Step Count 951 Switch Count 0
Page Faults 0
Page Reclaims 92
Page Swaps 0
Voluntary Context Switches 22
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 8


95
96 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
106

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@_maldini_ wrote:

@Reeza Something is obviously wrong w/ my revised syntax...

Revised syntax:

 

DATA meta.data_01;
	SET meta.data_01;
	
    RENAME 
                Map_Alpha1_V1=BH_ApoA1_V1;
                Map_Alpha1_V2=BH_ApoA1_V2;
                Map_Alpha1_V3=BH_ApoA1_V3;
                Map_Alpha2_V1=BH_ApoA2_V1;
                Map_Alpha2_V2=BH_ApoA2_V2;
                Map_Alpha2_V3=BH_ApoA2_V3;
                Map_Alpha3_V1=BH_ApoA3_V1;
                Map_Alpha3_V2=BH_ApoA3_V2;
                Map_Alpha3_V3=BH_ApoA3_V3;
                Map_Alpha4_V1=BH_ApoA4_V1;
                Map_Alpha4_V2=BH_ApoA4_V2;
                Map_Alpha4_V3=BH_ApoA4_V3;
                Map_PreB1_V1=BH_PreBeta_1_V1;
                Map_PreB1_V2=BH_PreBeta_1_V2;
                Map_PreB1_V3=BH_PreBeta_1_V3;
RUN;

 

 


In this case Your code only renames one variable.

RENAME Map_Alpha1_V1=BH_ApoA1_V1;

The semicolon here ends the rename. So the remaining statements like this are ASSIGNMENT statements:

Map_Alpha1_V2=BH_ApoA1_V2;

So if the data set does not have a variable BH_ApoA1_V2 the code 1) creates a variable of that name, 2) makes it with a missing a value and then 3) overwrites the existing variable Map_Alpha1_V2 with that missing value.

BTW, Proc Datasets will rename variables in place without use of a data step which can be much faster than the data step with large sets because it only changes the header information in the data set and does not process every record of the set like the data step must.

proc datasets library=meta;
   modify data_01;
   rename 
   			        Map_Alpha1_V1=BH_ApoA1_V1
				Map_Alpha1_V2=BH_ApoA1_V2
				Map_Alpha1_V3=BH_ApoA1_V3
				Map_Alpha2_V1=BH_ApoA2_V1
				Map_Alpha2_V2=BH_ApoA2_V2
				Map_Alpha2_V3=BH_ApoA2_V3
				Map_Alpha3_V1=BH_ApoA3_V1
				Map_Alpha3_V2=BH_ApoA3_V2
				Map_Alpha3_V3=BH_ApoA3_V3
				Map_Alpha4_V1=BH_ApoA4_V1
				Map_Alpha4_V2=BH_ApoA4_V2
				Map_Alpha4_V3=BH_ApoA4_V3
				Map_PreB1_V1=BH_PreBeta_1_V1
				Map_PreB1_V2=BH_PreBeta_1_V2
				Map_PreB1_V3=BH_PreBeta_1_V3
   ;

quit;

You can change labels, formats, informats as well. This procedure does not change the values of any of the data variables.

 

 

View solution in original post

8 REPLIES 8
Reeza
Super User

When you rename a variable, it stays the same just the name changes. 

So if you drop the variables that are renamed they are no longer in your data set. There are no old/new variables, just a single variable with a different name. 

 

So basically, the 'drop' is automatic and you don't need to drop anything. 

 


@_maldini_ wrote:

I'm trying to rename variables and then drop the originally named variables and keep the newly named ones. 

I have read this, this and this and cannot figure it out. 

DATA meta.data_01;
	SET meta.data_01;
	
	(RENAME =	(
				Map_Alpha1_V1=BH_ApoA1_V1
				Map_Alpha1_V2=BH_ApoA1_V2
				Map_Alpha1_V3=BH_ApoA1_V3
				Map_Alpha2_V1=BH_ApoA2_V1
				Map_Alpha2_V2=BH_ApoA2_V2
				Map_Alpha2_V3=BH_ApoA2_V3
				Map_Alpha3_V1=BH_ApoA3_V1
				Map_Alpha3_V2=BH_ApoA3_V2
				Map_Alpha3_V3=BH_ApoA3_V3
				Map_Alpha4_V1=BH_ApoA4_V1
				Map_Alpha4_V2=BH_ApoA4_V2
				Map_Alpha4_V3=BH_ApoA4_V3
				Map_PreB1_V1=BH_PreBeta_1_V1
				Map_PreB1_V2=BH_PreBeta_1_V2
				Map_PreB1_V3=BH_PreBeta_1_V3
				);


	DROP = 		(              
		 		Map:
               	);
RUN;

Log: 


1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 DATA meta.data_01;
70 SET meta.data_01;
71
72 (RENAME =(
_
180
ERROR 180-322: Statement is not valid or it is used out of proper order.

73 Map_Alpha1_V1=BH_ApoA1_V1
74 Map_Alpha1_V2=BH_ApoA1_V2
75 Map_Alpha1_V3=BH_ApoA1_V3
76 Map_Alpha2_V1=BH_ApoA2_V1
77 Map_Alpha2_V2=BH_ApoA2_V2
78 Map_Alpha2_V3=BH_ApoA2_V3
79 Map_Alpha3_V1=BH_ApoA3_V1
80 Map_Alpha3_V2=BH_ApoA3_V2
81 Map_Alpha3_V3=BH_ApoA3_V3
82 Map_Alpha4_V1=BH_ApoA4_V1
83 Map_Alpha4_V2=BH_ApoA4_V2
84 Map_Alpha4_V3=BH_ApoA4_V3
85 Map_PreB1_V1=BH_PreBeta_1_V1
86 Map_PreB1_V2=BH_PreBeta_1_V2
87 Map_PreB1_V3=BH_PreBeta_1_V3
88 );
89
90
91 DROP = (
92 Map:
_
388
200
76
ERROR 388-185: Expecting an arithmetic operator.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR 76-322: Syntax error, statement will be ignored.

93 );
94 RUN;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set META.DATA_01 may be incomplete. When this step was stopped there were 0 observations and 179 variables.
WARNING: Data set META.DATA_01 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 1431.56k
OS Memory 33204.00k
Timestamp 11/19/2021 08:46:47 PM
Step Count 951 Switch Count 0
Page Faults 0
Page Reclaims 92
Page Swaps 0
Voluntary Context Switches 22
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 8


95
96 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
106


 

_maldini_
Barite | Level 11

@Reeza Something is obviously wrong w/ my revised syntax...

Revised syntax:

 

DATA meta.data_01;
	SET meta.data_01;
	
    RENAME 
                Map_Alpha1_V1=BH_ApoA1_V1;
                Map_Alpha1_V2=BH_ApoA1_V2;
                Map_Alpha1_V3=BH_ApoA1_V3;
                Map_Alpha2_V1=BH_ApoA2_V1;
                Map_Alpha2_V2=BH_ApoA2_V2;
                Map_Alpha2_V3=BH_ApoA2_V3;
                Map_Alpha3_V1=BH_ApoA3_V1;
                Map_Alpha3_V2=BH_ApoA3_V2;
                Map_Alpha3_V3=BH_ApoA3_V3;
                Map_Alpha4_V1=BH_ApoA4_V1;
                Map_Alpha4_V2=BH_ApoA4_V2;
                Map_Alpha4_V3=BH_ApoA4_V3;
                Map_PreB1_V1=BH_PreBeta_1_V1;
                Map_PreB1_V2=BH_PreBeta_1_V2;
                Map_PreB1_V3=BH_PreBeta_1_V3;
RUN;

Log:

 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 DATA meta.data_01;
70 SET meta.data_01;
71
72 RENAME
73 Map_Alpha1_V1=BH_ApoA1_V1;
74 Map_Alpha1_V2=BH_ApoA1_V2;
75 Map_Alpha1_V3=BH_ApoA1_V3;
76 Map_Alpha2_V1=BH_ApoA2_V1;
77 Map_Alpha2_V2=BH_ApoA2_V2;
78 Map_Alpha2_V3=BH_ApoA2_V3;
79 Map_Alpha3_V1=BH_ApoA3_V1;
80 Map_Alpha3_V2=BH_ApoA3_V2;
81 Map_Alpha3_V3=BH_ApoA3_V3;
82 Map_Alpha4_V1=BH_ApoA4_V1;
83 Map_Alpha4_V2=BH_ApoA4_V2;
84 Map_Alpha4_V3=BH_ApoA4_V3;
85 Map_PreB1_V1=BH_PreBeta_1_V1;
86 Map_PreB1_V2=BH_PreBeta_1_V2;
87 Map_PreB1_V3=BH_PreBeta_1_V3;
88 RUN;
 
WARNING: The variable Map_Alpha1_V1 in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 49 observations read from the data set META.DATA_01.
NOTE: The data set META.DATA_01 has 49 observations and 171 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 1515.71k
OS Memory 32436.00k
Timestamp 11/19/2021 09:27:33 PM
Step Count 1146 Switch Count 2
Page Faults 0
Page Reclaims 104
Page Swaps 0
Voluntary Context Switches 49
Involuntary Context Switches 0
Block Input Operations 288
Block Output Operations 272
 
 
89
90 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
100
 
 

 

 

Reeza
Super User

Run it in a clean session from the start.

 

DATA meta.data_01;
	SET meta.data_01;

Coding like this is bad style and not recommended.

So likely what happened is you ran it once and it converted everything already. Now you run it again and the old variables are no longer there - you've already renamed them so it throws an error letting you know. 

 

So using the same name on DATA and SET statement is not recommended.

 


@_maldini_ wrote:

@Reeza Something is obviously wrong w/ my revised syntax...

Revised syntax:

 

DATA meta.data_01;
	SET meta.data_01;
	
    RENAME 
                Map_Alpha1_V1=BH_ApoA1_V1;
                Map_Alpha1_V2=BH_ApoA1_V2;
                Map_Alpha1_V3=BH_ApoA1_V3;
                Map_Alpha2_V1=BH_ApoA2_V1;
                Map_Alpha2_V2=BH_ApoA2_V2;
                Map_Alpha2_V3=BH_ApoA2_V3;
                Map_Alpha3_V1=BH_ApoA3_V1;
                Map_Alpha3_V2=BH_ApoA3_V2;
                Map_Alpha3_V3=BH_ApoA3_V3;
                Map_Alpha4_V1=BH_ApoA4_V1;
                Map_Alpha4_V2=BH_ApoA4_V2;
                Map_Alpha4_V3=BH_ApoA4_V3;
                Map_PreB1_V1=BH_PreBeta_1_V1;
                Map_PreB1_V2=BH_PreBeta_1_V2;
                Map_PreB1_V3=BH_PreBeta_1_V3;
RUN;

Log:

 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 DATA meta.data_01;
70 SET meta.data_01;
71
72 RENAME
73 Map_Alpha1_V1=BH_ApoA1_V1;
74 Map_Alpha1_V2=BH_ApoA1_V2;
75 Map_Alpha1_V3=BH_ApoA1_V3;
76 Map_Alpha2_V1=BH_ApoA2_V1;
77 Map_Alpha2_V2=BH_ApoA2_V2;
78 Map_Alpha2_V3=BH_ApoA2_V3;
79 Map_Alpha3_V1=BH_ApoA3_V1;
80 Map_Alpha3_V2=BH_ApoA3_V2;
81 Map_Alpha3_V3=BH_ApoA3_V3;
82 Map_Alpha4_V1=BH_ApoA4_V1;
83 Map_Alpha4_V2=BH_ApoA4_V2;
84 Map_Alpha4_V3=BH_ApoA4_V3;
85 Map_PreB1_V1=BH_PreBeta_1_V1;
86 Map_PreB1_V2=BH_PreBeta_1_V2;
87 Map_PreB1_V3=BH_PreBeta_1_V3;
88 RUN;
 
WARNING: The variable Map_Alpha1_V1 in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 49 observations read from the data set META.DATA_01.
NOTE: The data set META.DATA_01 has 49 observations and 171 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 1515.71k
OS Memory 32436.00k
Timestamp 11/19/2021 09:27:33 PM
Step Count 1146 Switch Count 2
Page Faults 0
Page Reclaims 104
Page Swaps 0
Voluntary Context Switches 49
Involuntary Context Switches 0
Block Input Operations 288
Block Output Operations 272
 
 
89
90 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
100
 
 

 

 


 

_maldini_
Barite | Level 11

@Reeza I'm getting the same warning even after quitting and restarting the session and changing the data set name in the DATA step.

Can anything be easy in SAS?!

Log:

 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 /* Creating the library */
70 LIBNAME meta "/home/...";
NOTE: Libref META was successfully assigned as follows:
Engine: V9
Physical Name: /home/...
71
72 /* */
73 /* PROC IMPORT DATAFILE="meta" */
74 /* OUT=meta_import */
75 /* DBMS=CSV */
76 /* replace; */
77 /* getnames=yes; */
78 /* RUN; */
79
80 *-------------------------------------------------;
81 * CREATING THE DATASET TO BE USED IN THE ANALYSES;
82 *-------------------------------------------------;
83
84 /* DATA meta.data_01; */
85 /* SET WORK.IMPORT; */
86 /* RUN; */
87
88 /* PROC CONTENTS DATA=meta.data_01; */
89 /* RUN; */
90
91 DATA meta.data_02;
92 SET meta.data_01;
93
94 RENAME
95 Map_Alpha1_V1=BH_ApoA1_V1;
96 Map_Alpha1_V2=BH_ApoA1_V2;
97 Map_Alpha1_V3=BH_ApoA1_V3;
98 Map_Alpha2_V1=BH_ApoA2_V1;
99 Map_Alpha2_V2=BH_ApoA2_V2;
100 Map_Alpha2_V3=BH_ApoA2_V3;
101 Map_Alpha3_V1=BH_ApoA3_V1;
102 Map_Alpha3_V2=BH_ApoA3_V2;
103 Map_Alpha3_V3=BH_ApoA3_V3;
104 Map_Alpha4_V1=BH_ApoA4_V1;
105 Map_Alpha4_V2=BH_ApoA4_V2;
106 Map_Alpha4_V3=BH_ApoA4_V3;
107 Map_PreB1_V1=BH_PreBeta_1_V1;
108 Map_PreB1_V2=BH_PreBeta_1_V2;
109 Map_PreB1_V3=BH_PreBeta_1_V3;
110
111 /* EFFLUX */
112 Efflux_V2_V1_diff = Efflux_V2-Efflux_V1;
113 Efflux_V3_V2_diff= Efflux_V3-Efflux_V2;
114 Efflux_V3_V1_diff= Efflux_V3-Efflux_V1;
115
116 /* CLEVELAND HEART LAB */
117 ApoA1_V2_V1_diff = ApoA1_V2-ApoA1_V1;
118 ApoA1_V3_V2_diff= ApoA1_V3-ApoA1_V2;
119 ApoA1_V3_V1_diff= ApoA1_V3-ApoA1_V1;
120
121 ApoC1_V2_V1_diff = ApoC1_V2-ApoC1_V1;
122 ApoC1_V3_V2_diff= ApoC1_V3-ApoC1_V2;
123 ApoC1_V3_V1_diff= ApoC1_V3-ApoC1_V1;
124
125 ApoC2_V2_V1_diff = ApoC2_V2-ApoC2_V1;
126 ApoC2_V3_V2_diff= ApoC2_V3-ApoC2_V2;
127 ApoC2_V3_V1_diff= ApoC2_V3-ApoC2_V1;
128
129 ApoC3_V2_V1_diff = ApoC3_V2-ApoC3_V1;
130 ApoC3_V3_V2_diff= ApoC3_V3-ApoC3_V2;
131 ApoC3_V3_V1_diff= ApoC3_V3-ApoC3_V1;
132
133 ApoC4_V2_V1_diff = ApoC4_V2-ApoC4_V1;
134 ApoC4_V3_V2_diff= ApoC4_V3-ApoC4_V2;
135 ApoC4_V3_V1_diff= ApoC4_V3-ApoC4_V1;
136
137 pCAD_V2_V1_diff = pCAD_V2-pCAD_V1;
138 pCAD_V3_V2_diff= pCAD_V3-pCAD_V2;
139 pCAD_V3_V1_diff= pCAD_V3-pCAD_V1;
140
141 /* BOSTON HEART */
142 BH_ApoA1_V2_V1_diff = BH_ApoA1_V2-BH_ApoA1_V1;
143 BH_ApoA1_V3_V2_diff= BH_ApoA1_V3-BH_ApoA1_V2;
144 BH_ApoA1_V3_V1_diff= BH_ApoA1_V3-BH_ApoA1_V1;
145
146 BH_ApoA2_V2_V1_diff = BH_ApoA2_V2-BH_ApoA2_V1;
147 BH_ApoA2_V3_V2_diff= BH_ApoA2_V3-BH_ApoA2_V2;
148 BH_ApoA2_V3_V1_diff= BH_ApoA2_V3-BH_ApoA2_V1;
149
150 BH_ApoA3_V2_V1_diff = BH_ApoA3_V2-BH_ApoA3_V1;
151 BH_ApoA3_V3_V2_diff= BH_ApoA3_V3-BH_ApoA3_V2;
152 BH_ApoA3_V3_V1_diff= BH_ApoA3_V3-BH_ApoA3_V1;
153
154 BH_ApoA4_V2_V1_diff = BH_ApoA4_V2-BH_ApoA4_V1;
155 BH_ApoA4_V3_V2_diff= BH_ApoA4_V3-BH_ApoA4_V2;
156 BH_ApoA4_V3_V1_diff= BH_ApoA4_V3-BH_ApoA4_V1;
157
158 Map_PreB1_V2_V1_diff = Map_PreB1_V2-Map_PreB1_V1;
159 Map_PreB1_V3_V2_diff= Map_PreB1_V3-Map_PreB1_V2;
160 Map_PreB1_V3_V1_diff= Map_PreB1_V3-Map_PreB1_V1;
161
162 /* MPO_Ab_V2_V1_diff */
163 /* MPO_Ab_V3_V1_diff */
164 /* MPO_Ab_V3_V2_diff */
165
166 /* LIVER & KIDNEY FX */
167 ALT_V2_V1_diff = ALT_V2-ALT_V1;
168 ALT_V3_V2_diff= ALT_V3-ALT_V2;
169 ALT_V3_V1_diff= ALT_V3-ALT_V1;
170
171 AST_V2_V1_diff = AST_V2-AST_V1;
172 AST_V3_V2_diff= AST_V3-AST_V2;
173 AST_V3_V1_diff= AST_V3-AST_V1;
174
175 AlkPhos_V2_V1_diff = AlkPhos_V2-AlkPhos_V1;
176 AlkPhos_V3_V2_diff= AlkPhos_V3-AlkPhos_V2;
177 AlkPhos_V3_V1_diff= AlkPhos_V3-AlkPhos_V1;
178
179 Bilirubin_V2_V1_diff = Bilirubin_V2-Bilirubin_V1;
180 Bilirubin_V3_V2_diff= Bilirubin_V3-Bilirubin_V2;
181 Bilirubin_V3_V1_diff= Bilirubin_V3-Bilirubin_V1;
182
183 Albumin_V2_V1_diff = Albumin_V2-Albumin_V1;
184 Albumin_V3_V2_diff= Albumin_V3-Albumin_V2;
185 Albumin_V3_V1_diff= Albumin_V3-Albumin_V1;
186
187 Globulin_V2_V1_diff = Globulin_V2-Globulin_V1;
188 Globulin_V3_V2_diff= Globulin_V3-Globulin_V2;
189 Globulin_V3_V1_diff= Globulin_V3-Globulin_V1;
190
191 TotalProt_V2_V1_diff = TotalProt_V2-TotalProt_V1;
192 TotalProt_V3_V2_diff= TotalProt_V3-TotalProt_V2;
193 TotalProt_V3_V1_diff= TotalProt_V3-TotalProt_V1;
194
195 AlbGlobRatio_V2_V1_diff = AlbGlobRatio_V2-AlbGlobRatio_V1;
196 AlbGlobRatio_V3_V2_diff= AlbGlobRatio_V3-AlbGlobRatio_V2;
197 AlbGlobRatio_V3_V1_diff= AlbGlobRatio_V3-AlbGlobRatio_V1;
198
199 BUN_V2_V1_diff = BUN_V2-BUN_V1;
200 BUN_V3_V2_diff= BUN_V3-BUN_V2;
201 BUN_V3_V1_diff= BUN_V3-BUN_V1;
202
203 Creatinine_V2_V1_diff = Creatinine_V2-Creatinine_V1;
204 Creatinine_V3_V2_diff= Creatinine_V3-Creatinine_V2;
205 Creatinine_V3_V1_diff= Creatinine_V3-Creatinine_V1;
206
207 BUNCreatinineRatio_V2_V1_diff = BUNCreatinineRatio_V2-BUNCreatinineRatio_V1;
208 BUNCreatinineRatio_V3_V2_diff= BUNCreatinineRatio_V3-BUNCreatinineRatio_V2;
209 BUNCreatinineRatio_V3_V1_diff= BUNCreatinineRatio_V3-BUNCreatinineRatio_V1;
210
211 eGFR_NoA_V2_V1_diff = eGFR_NoA_V2-eGFR_NoA_V1;
212 eGFR_NoA_V3_V2_diff= eGFR_NoA_V3-eGFR_NoA_V2;
213 eGFR_NoA_V3_V1_diff= eGFR_NoA_V3-eGFR_NoA_V1;
214
215 eGFR_AA_V2_V1_diff = eGFR_AA_V2-eGFR_AA_V1;
216 eGFR_AA_V3_V2_diff= eGFR_AA_V3-eGFR_AA_V2;
217 eGFR_AA_V3_V1_diff= eGFR_AA_V3-eGFR_AA_V1
218 ;
219
220 /* REMOVING OUTLIERS */
221 IF Creatinine_V1 = 73 THEN Creatinine_V1 = .;
222 RUN;
 
WARNING: The variable Map_Alpha1_V1 in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line):(Column).
2 at 112:34 2 at 114:33 49 at 142:38 49 at 143:38 49 at 144:38 49 at 146:38 49 at 147:38 49 at 148:38
49 at 150:38 49 at 151:38 49 at 152:38 49 at 154:38 49 at 155:38 49 at 156:38 49 at 158:41 49 at 159:40
49 at 160:40 49 at 167:28 49 at 168:27 49 at 171:28 49 at 172:27 49 at 175:36 49 at 176:35 49 at 179:40
49 at 180:39 49 at 183:36 49 at 184:35 49 at 187:37 49 at 188:37 49 at 191:40 49 at 192:39 49 at 195:45
49 at 196:45 49 at 199:28 49 at 200:27 49 at 203:42 49 at 204:41 1 at 205:41 49 at 207:58 49 at 208:57
41 at 209:57 49 at 211:37 49 at 212:37 49 at 215:36 49 at 216:35
NOTE: There were 49 observations read from the data set META.DATA_01.
NOTE: The data set META.DATA_02 has 49 observations and 171 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
user cpu time 0.01 seconds
system cpu time 0.01 seconds
memory 1334.84k
OS Memory 24744.00k
Timestamp 11/19/2021 09:54:32 PM
Step Count 36 Switch Count 1
Page Faults 0
Page Reclaims 220
Page Swaps 0
Voluntary Context Switches 43
Involuntary Context Switches 0
Block Input Operations 320
Block Output Operations 280
 
 
223
224
225 /* PROC PRINT DATA=meta.data_01; */
226 /* Var Participant_ID; */
227 /* RUN; */
228 /* */
229 /* PROC CONTENTS DATA=meta.data_01 VARNUM; RUN; */
230
231
232
233 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
243
PaigeMiller
Diamond | Level 26

The WARNING is extremely clear. The variable named MAP_ALPHA1_V1 is not in your data set, so you can't rename it.

 

You can see this by yourself by actually looking at the data set, or by looking at PROC CONTENTS for that data set.

--
Paige Miller
Reeza
Super User
Then if it's for just a single one, you're likely wrong and the computer is right, the variable doesn't exist in your input data set.
So it likely has a different name, spaces, spelling or something is off in the name.

ballardw
Super User

@_maldini_ wrote:

@Reeza Something is obviously wrong w/ my revised syntax...

Revised syntax:

 

DATA meta.data_01;
	SET meta.data_01;
	
    RENAME 
                Map_Alpha1_V1=BH_ApoA1_V1;
                Map_Alpha1_V2=BH_ApoA1_V2;
                Map_Alpha1_V3=BH_ApoA1_V3;
                Map_Alpha2_V1=BH_ApoA2_V1;
                Map_Alpha2_V2=BH_ApoA2_V2;
                Map_Alpha2_V3=BH_ApoA2_V3;
                Map_Alpha3_V1=BH_ApoA3_V1;
                Map_Alpha3_V2=BH_ApoA3_V2;
                Map_Alpha3_V3=BH_ApoA3_V3;
                Map_Alpha4_V1=BH_ApoA4_V1;
                Map_Alpha4_V2=BH_ApoA4_V2;
                Map_Alpha4_V3=BH_ApoA4_V3;
                Map_PreB1_V1=BH_PreBeta_1_V1;
                Map_PreB1_V2=BH_PreBeta_1_V2;
                Map_PreB1_V3=BH_PreBeta_1_V3;
RUN;

 

 


In this case Your code only renames one variable.

RENAME Map_Alpha1_V1=BH_ApoA1_V1;

The semicolon here ends the rename. So the remaining statements like this are ASSIGNMENT statements:

Map_Alpha1_V2=BH_ApoA1_V2;

So if the data set does not have a variable BH_ApoA1_V2 the code 1) creates a variable of that name, 2) makes it with a missing a value and then 3) overwrites the existing variable Map_Alpha1_V2 with that missing value.

BTW, Proc Datasets will rename variables in place without use of a data step which can be much faster than the data step with large sets because it only changes the header information in the data set and does not process every record of the set like the data step must.

proc datasets library=meta;
   modify data_01;
   rename 
   			        Map_Alpha1_V1=BH_ApoA1_V1
				Map_Alpha1_V2=BH_ApoA1_V2
				Map_Alpha1_V3=BH_ApoA1_V3
				Map_Alpha2_V1=BH_ApoA2_V1
				Map_Alpha2_V2=BH_ApoA2_V2
				Map_Alpha2_V3=BH_ApoA2_V3
				Map_Alpha3_V1=BH_ApoA3_V1
				Map_Alpha3_V2=BH_ApoA3_V2
				Map_Alpha3_V3=BH_ApoA3_V3
				Map_Alpha4_V1=BH_ApoA4_V1
				Map_Alpha4_V2=BH_ApoA4_V2
				Map_Alpha4_V3=BH_ApoA4_V3
				Map_PreB1_V1=BH_PreBeta_1_V1
				Map_PreB1_V2=BH_PreBeta_1_V2
				Map_PreB1_V3=BH_PreBeta_1_V3
   ;

quit;

You can change labels, formats, informats as well. This procedure does not change the values of any of the data variables.

 

 

_maldini_
Barite | Level 11
Solved. Thank you!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 8 replies
  • 2263 views
  • 7 likes
  • 4 in conversation