仅在sas中使用宏变量创建(%let)创建宏 [英] create a macro only with macro variables creation (%let) in sas

查看:595
本文介绍了仅在sas中使用宏变量创建(%let)创建宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个仅包含创建宏变量但失败的宏.这是一个示例:

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;

但是它将作为:

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

所以我想知道SAS是否不能仅创建宏变量而创建宏?还是有办法解决这个问题.谢谢.

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.

推荐答案

尝试

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

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

这篇关于仅在sas中使用宏变量创建(%let)创建宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆