您好我正在尝试构建一个宏进程,允许我将数据从最近一个月拉到x个月(历史上),但是它似乎只拉了一个月的任何想法?
%LET START_DATE = 20140731;
DATA _NULL_;
START_DATE = input(cat(&START_DATE),YYMMN6.);
FORMAT START_DATE date9.;
MON_START_DT=put(START_DATE,date9.);
CALL SYMPUTX('MON_START_DT',put(MON_START_DT,9.));
RUN;
%MACRO DO_FOR(NUM_OF_MONTHS);
%DO I = 0 %TO &NUM_OF_MONTHS-1;
DATA _NULL_;
END_DATE=intnx('month',"&MON_START_DT"d,&I,'end');
FORMAT END_DATE yymmdd10.;
MON_END_DATE=put(END_DATE,yymmdd10.);
MON_END_DATE=COMPRESS(MON_END_DATE," (-)");
FORMAT MON_END_DATE $8.;
CALL SYMPUTX('BATCH_ID',put(MON_END_DATE,$8.));
RUN;
PROC SQL;
sysecho;
CREATE TABLE work.table AS
SELECT FROM WHERE
/*ex This table contains months of data*/
%END;
%MEND DO_FOR;
%DO_FOR(NUM_OF_MONTHS=03);
答案 0 :(得分:0)
不应该&I
前面有一个减号,以便及时倒退而不是及时前进?如果你从当前月份开始只前进一个月,你将只能获得一个月。
END_DATE=intnx('month',"&MON_START_DT"d,-&I,'end');