您可以使用调用symputX和Global选项来确保宏变量在宏外可用。我想知道你为什么需要一个宏,但是:)。 您可能还想了解SAS存储日期的方式,因为它们是应用格式的数字。
%MACRO Getdate;
DATA _null_;
infile 'h:\dates.txt';
input @1 date date9.;
call symputx('date_stored', put(date, date9.), G);
run;
%MEND Getdate;
%getdate;
%put &date_stored.;
编辑:根据你的答案/下面的评论:
%MACRO Getdate;
%let date_stored=0;
DATA _null_;
infile 'h:\dates.txt';
input @1 date date9.;
call symputx('date_stored', put(date, date9.), G);
call symputx('start_date', put(date-45, date9.), G);
call symputx('end_date', put(date-14, date9.), G);
run;
%MEND Getdate;
*CHECK if they exist after macro is run;
%put &date_stored;
%put &start_date;
%put &end_date;
有几个方法可以做到这一点。检查doco中数据步骤中的'symput'函数。你可能不需要一个已命名的数据集,你可以使用'data _null_'。 – sasfrog 2014-10-02 02:54:47
谢谢sasfrog,我确实看过这些,Reese的逻辑帮助我解决了这个问题。绝对感谢您的意见:)) – vbala2014 2014-10-03 15:15:06