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_ 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.
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
@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:
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;6869 DATA meta.data_01;70 SET meta.data_01;7172 RENAME73 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 secondsuser cpu time 0.00 secondssystem cpu time 0.00 secondsmemory 1515.71kOS Memory 32436.00kTimestamp 11/19/2021 09:27:33 PMStep Count 1146 Switch Count 2Page Faults 0Page Reclaims 104Page Swaps 0Voluntary Context Switches 49Involuntary Context Switches 0Block Input Operations 288Block Output Operations 2728990 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;100
@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;6869 /* Creating the library */70 LIBNAME meta "/home/...";NOTE: Libref META was successfully assigned as follows:Engine: V9Physical Name: /home/...7172 /* */73 /* PROC IMPORT DATAFILE="meta" */74 /* OUT=meta_import */75 /* DBMS=CSV */76 /* replace; */77 /* getnames=yes; */78 /* RUN; */7980 *-------------------------------------------------;81 * CREATING THE DATASET TO BE USED IN THE ANALYSES;82 *-------------------------------------------------;8384 /* DATA meta.data_01; */85 /* SET WORK.IMPORT; */86 /* RUN; */8788 /* PROC CONTENTS DATA=meta.data_01; */89 /* RUN; */9091 DATA meta.data_02;92 SET meta.data_01;9394 RENAME95 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;110111 /* 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;115116 /* 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;120121 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;124125 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;128129 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;132133 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;136137 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;140141 /* 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;145146 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;149150 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;153154 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;157158 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;161162 /* MPO_Ab_V2_V1_diff */163 /* MPO_Ab_V3_V1_diff */164 /* MPO_Ab_V3_V2_diff */165166 /* 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;170171 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;174175 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;178179 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;182183 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;186187 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;190191 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;194195 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;198199 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;202203 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;206207 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;210211 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;214215 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_V1218 ;219220 /* 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:3849 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:4049 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:4049 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:4549 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:5741 at 209:57 49 at 211:37 49 at 212:37 49 at 215:36 49 at 216:35NOTE: 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 secondsuser cpu time 0.01 secondssystem cpu time 0.01 secondsmemory 1334.84kOS Memory 24744.00kTimestamp 11/19/2021 09:54:32 PMStep Count 36 Switch Count 1Page Faults 0Page Reclaims 220Page Swaps 0Voluntary Context Switches 43Involuntary Context Switches 0Block Input Operations 320Block Output Operations 280223224225 /* PROC PRINT DATA=meta.data_01; */226 /* Var Participant_ID; */227 /* RUN; */228 /* */229 /* PROC CONTENTS DATA=meta.data_01 VARNUM; RUN; */230231232233 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;243
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.
@_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.
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!
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.