0

我正在尝试使用嵌入在 SAS 宏中的临时数组,但无法识别何时尝试从那里获取值。这是我的 SAS 代码的一部分:

array months{13} $ _temporary_ ( 'MAR2019' 'APR2019' 'MAY2019' 'JUN2019' 'JUL2019' 'AUG2019' 'SEP2019' 
                   'OCT2019' 'NOV2019' 'DEC2019' 'JAN2020' 'FEB2020' 'MAR2020');
array monthExpA{13} _temporary_ ('31MAR2019'd '30APR2019'd '31MAY2019'd '30JUN2019'd '31JUL2019'd '31AUG2019'd '30SEP2019'd 
                   '31OCT2019'd '30NOV2019'd '31DEC2019'd '31JAN2020'd '29FEB2020'd 70.6);
array monthExpB{13} _temporary_ (&clockstartdate '01APR2019'd '01MAY2019'd '01JUN2019'd '01JUL2019'd '01AUG2019'd '01SEP2019'd 
                   '01OCT2019'd '01NOV2019'd '01DEC2019'd '01JAN2020'd '01FEB2020'd 70.6);

array totExpectp{13} totExpectp1-totExpectp13;

month1 = 'Feb2019';
monthExpect1 = 0;
totalExpect1 = 0;
flg = 0;
totExpectp[1] = 0;



%do i = 1 %to 13; %put putn(monthExpA[&i],date9.);
    flg = 0;
    month = months[&i];
    %let cutoffd = %totalExpect(monthExpA[i],0); 
    %put &cutoffd;
    %if %sysfunc(month(/*monthExpA[i]*/ cutoffd)) eq %sysfunc(month(&cutoffdate)) 
        and %sysfunc(year(/*monthExpA[i]*/'22Apr2019'd)) eq %sysfunc(year(&cutoffdate)) %then %do;
        %put "Test0;";
        flg = 1;
        %put cutoffd;
    %end;%end;

我的主要问题是如何让程序识别这个变量monthExpA [i]?我真的很感谢你的帮助。谢谢!

4

1 回答 1

0

您无法将宏代码识别monthExpA[i]为 12 个字符的字符串以外的任何内容。您需要使用普通的 SAS 代码来使用数组。

do i=1 to 13;
  flg = 0;
  month = months[i];
  ...      
于 2019-04-23T21:17:07.263 回答