create a macro only with macro variables creation (%let) in sas

﹥>﹥吖頭↗ 提交于 2019-12-25 18:00:28

问题


Hi I was trying to create a macro that only contains macro variable creation but it failed. Here is an example:

%macro createvariable; 
    %let a = 5;
    %let b = 6;
%mend createvariable;
%createvariable; 

data test; 
    c = &a + &b;
run;

But it will work as:

%macro createvariable; 
    %let a = 5;
    %let b = 6;
data test; 
    c = &a + &b;
run;
%mend createvariable;
%createvariable; 

So I was wondering if SAS won't be able to create a macro with only macro variables creation in it? Or there is a way to solve this problem. Thanks.


回答1:


Try

%macro createvariable; 
%global a b;
    %let a = 5;
    %let b = 6;
%mend createvariable;
%createvariable; 

data test; 
    c = &a + &b;
run;


来源:https://stackoverflow.com/questions/50827584/create-a-macro-only-with-macro-variables-creation-let-in-sas

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!