Note that there are some explanatory texts on larger screens.

plurals
  1. POSAS Macro Do Loop not resolving
    primarykey
    data
    text
    <p>Can anybody tell me why this isn't resolving:</p> <pre><code>/*put all transaction table names into a data set*/ /*(table names are of format transac_20130603_20130610 (date from and date to)*/ data transaction_tables; set SASHELP.VTABLE (keep=libname memname); where lowcase(substr(memname,1,8))='transac_' run; /*sort and add rownumbers*/ proc sql; create table transaction_tables as select *, monotonic() as rownum from transaction_tables order by memname; run; /*find rownumber of first and last transaction tables with run dates before campaign start and after end date of campaign*/ data _NULL_; set transaction_tables; if substr(memname,9,8)&lt;=&amp;pre_period_start. and substr(memname,18,8)&gt;=&amp;pre_period_start. then do; call symput("r1", rownum); stop; end; run; data _NULL_; set transaction_tables; if substr(memname,9,8)&lt;=&amp;max_enddate. and substr(memname,18,8)&gt;=&amp;max_enddate. then do; call symput("r2", rownum); stop; end; run; %put &amp;r1; %put &amp;r2; /*r1 = 11, r2 = 27 - both resolving OK*/ /*get all relevant transaction table names where rownumbers are between r1 and r2*/ /*r1=11 and r2=27 so my transaction table name macros should run from t_0 to t_16/* %macro trans; %let y = %eval(&amp;r2 - &amp;r1); %do i=0 %to &amp;y; data _NULL_; set transaction_tables; if rownum = &amp;r2 - (&amp;r2 - &amp;r1 - &amp;i) then do; call symput("t_&amp;i", cats(libname, '.', memname)); stop; end; %end; %mend trans; %trans; %put &amp;t_0; --WARNING: Macro variable "&amp;t_0" was not resolved </code></pre> <p>i'm not entirely sure why but from messing around with a few of the variables i think the problem lies with the last part where it is attempting to assign table names to t_&amp;i macros. i think the issue is with trying to name a macro variable while trying to call another macro variable (trying to create macro t_0 by calling &amp;i when i=0). i guess i've screwed something up with the syntax because i <em>think</em> the logic is fairly sound.</p> <p>thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload