Reputation: 3099
I imported a dataset with getnames=no
proc import out=dstest
datafile
...
run;
and got a bunch of F1-F5
variables
Now I want to rename them
data dstest (rename=(F2=newName));
set dstest ;
run;
Here is the error
The variable F2 in the DROP, KEEP, or RENAME list has never been referenced
data dstest ;
set dstest(rename=(F2=newName)) ;
run;
Here is the error
Variable F2 is not on file WORK.dstest.
However proc print works fine
proc print data=tortdata (obs=10) ;
var F2;
run;
Upvotes: 0
Views: 1434
Reputation: 63434
There's nothing inherently wrong with what you've posted, insomuch as the code should run:
data blah;
f1=1;
f2=4;
run;
data blah(rename=(f1=a f2=b));
set blah;
run;
However, if you're just renaming the variable, no reason to do a data step. PROC DATASETS
can handle this without going through the entire dataset. This may not matter much if the dataset is small, but if it is large, this may save a lot of time. Note that you can't run the above and then this, as f1 and f2 will be gone if you don't re-construct the blah
dataset.
proc datasets lib=work;
modify blah;
rename f1=a f2=b;
quit;
Upvotes: 2