Reputation: 12701
How do I convert a SAS date such as "30JUL2009"d
into YYYYMMDD
format (eg 20090730)?
So for instance:
data _null_;
format test ?????;
test=today();
put test=;
run;
Would give me "test=20090730" in the log...
Upvotes: 17
Views: 105895
Reputation: 5085
There is this one that should do the trick too
%let today=%sysfunc(today(),yymmddn8.);
%put &today.;
Everything on the link below
https://communities.sas.com/thread/60111
Upvotes: 3
Reputation: 751
You can see all date and time formats in Help tab when you enter 'date' to Index tab and then selecr 'date and time formats'
Upvotes: 0
Reputation:
%let expectdate1=%sysfunc(putn(%eval(%sysfunc(today())-1),yymmddn8.));
You want to use the format yymmddn8. The 'n' means no separator.
Per http://support.sas.com/kb/24/610.html you can specify B for blank, C for colon, D for dash, N for no separator, P for period, or S for slash.
Upvotes: 14
Reputation: 12701
here's how I did it in macro, but surely there must be a format??!!!
%let today=%sysfunc(compress(%sysfunc(today(),yymmddd10.),'-'));
its weird - the INFORMAT yymmdd8. gives YYYYMMDD result, whereas the FORMAT yymmdd8. gives a YY-MM-DD result!!
Upvotes: 2