Reputation: 5183
How to get sas date format "YYYYMM" in SAS ?
From this code below I would get '2011-11-01'
call symput('me',"'"||put(intnx('month',today(),-1 ),yymmdd10.)||"'");
I'm trying to get something like : '2011-11'
Thanks
Upvotes: 4
Views: 46491
Reputation: 6207
For more information on formats visit http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002231336.htm
You can use one of the examples or "create" your own.
For example:
data datum;
datum=date();
datum1mback= INTNX( 'month', datum, -1);
format datum1mback yymmn6.; /* returns 201111 (if we consider the date of the question of course) */
run;
/* yymmp6. returns 11.11 */
/* yymmc8. returns 2011:11 */
/*...*/
Upvotes: -1
Reputation: 8513
Macro version:
%let date = %sysfunc(today());
%let me = %str(%")%sysfunc(intnx(month,&date,-1),yymmd7.)%str(%");
%put &me;
Upvotes: 5
Reputation: 1511
You can replace yymmdd10. with yymmd7. that should be the format you want.
Upvotes: 5