You have no SET statement.
A SET statement tells SAS what the input data set is. Since there is none, there is no data to work with in that step.
The data step actually deletes your initial step and replaces that data with nothing.
This is probably what you want but not a good idea. Whenever you have a data step its not a good idea to have your SET and DATA reference the same data set. This destroys your original data set so if you make a mistake you have to go back extra steps.
data mylib.test;
set mylib.test;
rename var1 = ID;
run;
Instead you can build on it:
data mylib.test2;
set mylib.test;
rename var1 = ID;
run;
Or use PROC DATASETS to rename the variable. This is actually the fastest, most efficient option as it just changes the metadata/variable name. In a Data step or SQL proc it actually go through all the data and recreates a new data set at the end.
proc datasets lib=mylib;
modify test;
rename var1=id;
run;quit;
@Abdulla1 wrote:
Thanks that works very well.
however, I'm trying to change the variable var1 into ID can I do that without setting new variable
I tried the code below but it didn't work either.
proc sql;
create table mylib.test as
select *
from lib1.data1
where var2='202220'
order by var3, var4;
quit;
data mylib.test;
rename var1=ID;
run;