BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cau83
Pyrite | Level 9

My code is for testing forecasting models on a holdout sample in order to test and do forecast value added analysis so that we can do model selection. Using PROC ESM, we have 8 model choices and then we also need to perform a 2 week forecast for each of the 6 weeks (so I have a 1 to 8 loop for the model choices and a 1 to 6 loop for the weeks). Here's the code:

%macro modeltest(Dept=,holdoutweeks=);

  %let modelname1=simple;

  %let modelname2=double;

  %let modelname3=linear;

  %let modelname4=damptrend;

  %let modelname5=addseasonal;

  %let modelname6=multseasonal;

  %let modelname7=winters;

  %let modelname8=addwinters;

  %do J = 1 %to 2; **loops through the 8 different model choices and does the 6 weeks of forecasting for each**;

       %let modelspec=&modelname&j;    (*********THE PROBLEM OCCURS HERE********)

       %DO I = 1 %TO 1;

            %let backpd=%eval((&holdoutweeks+1)*7 - (&i*7)); **backpd = # of days to go back but divided by i so it loops through one week at a time**;

            proc esm data=&Dept back=&BackPd lead=14 seasonality=7 nooutall outfor=fcast_&Dept._&i._&modelspec outstat=metrics_&Dept._&i._&modelspec out=_null_;

                 by queue_nm lob;

                 id date interval=day zeromiss=left;

                 forecast effort/ model=&modelspec;

            run;

       %end;

  %end;

%mend;

%modeltest(Dept=OSS,holdoutweeks=6);

I get an unnecessary warning (or, it is necessary and I do not yet realize the impact it could have, hence my question) on the line where I ID'd a problem. I want &modelspec to step through the 8 models each time, so be equal to &modelname1 then &modelname2 and so on. I'll selectively copy and paste some lines from the log to show the warning and that (I believe) it is ultimately working anyway:

     MLOGIC(MODELTEST):  %LET (variable name is MODELSPEC)

     WARNING: Apparent symbolic reference MODELNAME not resolved.

     SYMBOLGEN:  Macro variable J resolves to 1

     SYMBOLGEN:  Macro variable MODELSPEC resolves to &modelname1

It appears that SAS is evaluating "&modelname" first before evaluating the entire "&modelname&j". Should I be concerned about this warning and how can I get rid of it? Is there a different way to do the specification?

I am also having a problem with naming the output data sets, but I posted that separately here: https://communities.sas.com/thread/48073 .  thanks for any help/ideas.

-Chris

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

try changing %let modelspec=&modelname&j;

to

%let modelspec=&&modelname&j;

View solution in original post

3 REPLIES 3
Linlin
Lapis Lazuli | Level 10

try changing %let modelspec=&modelname&j;

to

%let modelspec=&&modelname&j;

cau83
Pyrite | Level 9

Linlin, that worked thanks.

Now I get in the log:

SYMBOLGEN:  && resolves to &.

Just curious now: So the double ampersand tells SAS to... what exactly? How does this work?

Linlin
Lapis Lazuli | Level 10

first time resolves

&&modelname&j to  &modelname1

second time resolves

&modelname1 to simple.


sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1502 views
  • 0 likes
  • 2 in conversation