我创建了下面的宏,以便根据日期宏生成一些数据集。
%macro pull(date);
proc sql;
create table new&date as
select * from acct
where date=&date.;
quit;
%mend;因此,如果我想创建20170101 20170201 20170301 20170401 20170501数据集,我能做的就是使用下面的宏
%macro pull(20170101)
%macro pull(20170201)
%macro pull(20170301)
%macro pull(20170401)
%macro pull(20170501)我现在计划创建两个宏变量
%let begin=20170101;
%let end =20170501;并基于begin和end using循环创建数据集。我想要做的是将开始日期和结束日期作为宏变量,并从帐户数据集中提取开始日期和结束日期之间的记录,并为开始日期和结束日期之间的每个月创建单独的数据集,这是可能的吗?我想要做的是将开始日期和结束日期作为宏变量,并从帐户数据集中提取开始日期和结束日期之间的记录,并为每个月创建单独的that.So数据集
注数据集具有每年的每月日期。
下面是我正在尝试的代码
%let beg="01jan2000"d;
%let end="01jan2001"d;
%macro Test;
%do date=&beg. %to &end.;
proc sql;
create table IPw_&date. as
select *
from sample
where date=&date. quit;
%end;
%mend;
%Test;发布于 2018-04-28 22:56:37
%macro pull(begin,end);
%let i=0;
%let begin=%sysfunc(inputn(&begin,anydtdte9.));
%let end=%sysfunc(inputn(&end,anydtdte9.));
%do %until (&begin=&end);
%let begin=%sysfunc(intnx(month,&begin,&i));
%let date=%sysfunc(putn(&begin,yymmddn8.));
proc sql;
create table new&date as
select * from acct where date=&date.;
quit;
%let i=%eval(&i+1);
%end;
%mend;
%pull(20170101,20170501)https://stackoverflow.com/questions/50075939
复制相似问题