I’m trying to create a table by
However, when I use this code below, it keeps replacing the newest variable instead of adding them . .. So instead of a table with 100+ variables, I end up with a table with just a couple. Where am I going wrong?
%macro test;
%do i=1 %to 110;
data got&i;
set have (keep=date var&i);
run;
proc expand data= got&i out=want&i;
convert var&i = new_var&i /transformout=(movave 4);
run;
proc sql;
create table final as
select a.*, b. new_var&i
from semifinal a
left join want&i b on a.date=b.date;
quit;
%end;
%mend;
%testmacro;
I don't know what is in you table Semifinal but you keep replacing the table Final with the contents of Semifinal and one variable.
I expect that you only have the 110th variable in last version of Final. If I understand what you may be attempting you need to do something after each "create table final" to make it the table semifinal. Maybe:
proc sql;
create table final as
select a.*, b. new_var&i
from semifinal a
left join want&i b on a.date=b.date;
Create table semifinal as
select * from final;
quit;
I don't know what is in you table Semifinal but you keep replacing the table Final with the contents of Semifinal and one variable.
I expect that you only have the 110th variable in last version of Final. If I understand what you may be attempting you need to do something after each "create table final" to make it the table semifinal. Maybe:
proc sql;
create table final as
select a.*, b. new_var&i
from semifinal a
left join want&i b on a.date=b.date;
Create table semifinal as
select * from final;
quit;
Thank you ballardw! That did the trick.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.