Hi, folks -
I want to develop some statistical models using different training samples and then test their forecasting power on different holdout sample. For this purpose, I used window rolling approach in where both training and holdout sample move ahead untile specific year.
%let LT=2000;
%let UT=2005;
%let LH=2006;
%let UH=2008;
%macro_static_models(LT=<, UT=&UT, LH=&LH, UH=&UH);
so in the next round, I want to move one year ahead and have;
%let LT=2001;
%let UT=2006;
%let LH=2007;
%let UH=2009;
% macro_static_models (LT=<, UT=&UT, LH=&LH, UH=&UH) ;
the LT will stop at 2009. Do you have any suggestion how can I incorporate Do loop?
Thanks
Use call execute.
data want;
lt=1999; ut=2004;
do i=1 to 10;
lt=lt+1;
ut=ut+1;
str=cats('%macro_static_models(LT=', lt, ',UT=', UT, ');');
call execute(str);
end;
run;
Using call execute to call a macro is safer if you prevent macro expansion at the call time with %nrstr.
data _null_;
length line $200;
do lt = 2000 to 2009;
line = cats('%nrstr(%macro_static_models(LT=', lt, ',UT=', lt+5, ',LH=', lt+6, ',UH=', lt+8, '));');
call execute(line);
end;
run;
many thanks for your reply. Actually, I forgot to add something else. I need to define new libraries for each round of tests.
I use the last two digits of each year as a proxy for lib names, e.g. S<S&UHS&Y.C.
%let LT=2000;
%let UT=2005;
%let LH=2006;
%let UH=2008;
%let LTS=00;
%let UTS=05;
%let LHS=06;
%let UHS=08;
%macro_static_models(LT=<, UT=&UT, LH=&LH, UH=&UH);
Would you please kindly help me ? thanks
I'm not sure how that changes anything. You can use the libname function inside a data null step to create the library based on the LT/UT variables.
Why are you creating macro variables outside your process, its better to keep it internal to your process.
data _null_;
lts=substr("<", 3, 2);
uts=substr("&ut", 3, 2);
rc=libname(cats(dir, lts, uts));
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.