Automating the starting date with a macro variable in SAS -


background: have code pulls transactional data starting @ beginning of current calendar quarter, year ago. example, if run code today (august 16, 2013) have pull data july 1, 2012 onwards.

problem: want automate starting date data pull macro variable.

so far, i'm stuck here:

%let thisyear = %sysfunc(date(), year.); %let lastyear= %eval(&thisyear-1); /* starting year */  %let qtr_start_month= %eval(3*%sysfunc(date(), qtr.)-2); /* gives me current quarter starting month. if run in august, outputs 7 july */  %let start_date=%str(01/%sysfunc(month(&qtr_start_month))/&lcy); 

the final macro variable outputs date want, in format not recognized sas.

i appreciate help. many in advance!

you can either input date date format, or construct sas date literal ('01jul2013'), ddmonyy(yy), or construct date value directly.

intnx best option here construct it; don't need work.

%let start_date = %sysfunc(intnx(quarter,%sysfunc(date()),-4),date9.); %put &start_date; 

you can leave date9. use date literal, or remove ,date9. numeric value can used directly. use "&start_date."d use date literal.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -