在SAS%do中使用函数

在SAS%do中使用函数,sas,Sas,我正在尝试开始使用SAS。我创建了一个数据集,其中变量的数量取决于用户选择的周期。我想做的是循环这些变量。我尝试使用的宏是(示例中我调整了fixed date): 不幸的是,运行此宏会产生以下错误: ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: %sysfunc(intck('

我正在尝试开始使用SAS。我创建了一个数据集,其中变量的数量取决于用户选择的周期。我想做的是循环这些变量。我尝试使用的宏是(示例中我调整了fixed date):

不幸的是,运行此宏会产生以下错误:

ERROR: A character operand was found in the %EVAL function or %IF 
condition where a numeric operand is required. 
The condition was: %sysfunc(intck('month', "01JUL2008"d, "31JUL2009"d)) 
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro DO_PERIOD will stop executing.
我尝试了多种方法来计算intck函数(例如,使用输入(…)计算%eval(%sysfunc(…),但没有任何结果。我希望你们中有人知道在%do语句中计算函数的答案。

有几个问题:

  • 在宏中,不需要引用文本(例如“月”),所有内容都被视为文本
  • %put语句中缺少分号
  • 您需要一个符号和来表示宏变量(不是%符号,它调用
  • 见:


    非常感谢你!将代码放入StackExchange时,文件和是一个输入错误。经过一些实验,我发现真正的问题是“月”左右的引号。不考虑这些就解决了问题!
    ERROR: A character operand was found in the %EVAL function or %IF 
    condition where a numeric operand is required. 
    The condition was: %sysfunc(intck('month', "01JUL2008"d, "31JUL2009"d)) 
    ERROR: The %TO value of the %DO I loop is invalid.
    ERROR: The macro DO_PERIOD will stop executing.
    
    %MACRO DO_PERIOD;
      %DO I = 1 %TO %SYSFUNC(intck(MONTH, "01JUL2008"d,"31JUL2009"d)); 
        %PUT &I; 
      %END; 
    %MEND; 
    %DO_PERIOD;