- option spool;
- %macro a;
- data _null_;
- call symput('mon',intck("month",'01dec2020'd,(today())));
- run;
- data sub_obs_mon;
- do i=1 to &mon.;
- today=today();
- obs_dt=intnx('month','01dec2020'd,i,"end");
- format obs_dt today yymmdd10.;
- y=year(obs_dt);
- m=month(obs_dt);
- d=day(obs_dt);
- output;
- end;
- keep obs_dt y m d;
- run;
- data _null_;
- set sub_obs_mon nobs=n;
- call symput('n',n);
- call symput('dt_'||left(_n_),compress(obs_dt));
- call symput('y_'||left(_n_),compress(y));
- call symput('m_'||left(_n_),compress(m));
- call symput('d_'||left(_n_),compress(d));
- run;
- %do i=1 %to &n.;
- %local tjyf_&i. dt_&i y_&i. m_&i. d_&i.;
- %let obs_dt=%sysfunc(mdy(%sysfunc(inputn(&&m_&i,best12.)),%sysfunc(inputn(&&d_&i,best12.)),%sysfunc(inputn(&&y_&i,best12.))));
- %end;
- %do i=1 %to &n.;
- data a_&i.;
- date=&obs_dt;
- dt=%sysfunc(inputn(&&dt_&i,yymmdd10.));
- format date dt yymmdd10.;
- run;
- %end;
- %mend;
- %a;