在SAS宏中使用临时阵列

问题描述 投票:0回答:1

我正在尝试使用嵌入在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]?我非常感谢你的帮助。谢谢!

arrays sas sas-macro
1个回答
0
投票

您无法获取宏代码来将monthExpA[i]识别为除12个字符的字符串之外的任何内容。您需要使用普通的SAS代码来使用阵列。

do i=1 to 13;
  flg = 0;
  month = months[i];
  ...      
© www.soinside.com 2019 - 2024. All rights reserved.