BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I define a global variable as follows:
%let todaydate=today();
and SAS assign a number to the 'todaydate'. Anyone knows whether it is possible for me to format the 'todaydate', e.g. ddmmyy or ddmonyy etc?
5 REPLIES 5
LinusH
Tourmaline | Level 20
Try

%let todaydate = %sysfunc(putn("&SYSDATE9"D,ddmmyy.));

Regards,
Linus
Data never sleeps
Cynthia_sas
SAS Super FREQ
Hi:
If you DO want to use the today() function instead of &SYSDATE9, you can use it directly in the %LET, and with the TODAY() function, a second argument is allowed for %SYSFUNC that formats the returned date:
[pre]
%let d1 = %sysfunc(today(),ddmmyy.);
%let d2 = %sysfunc(today(),worddate.);
%let d3 = %sysfunc(today(),mmddyy10.);
%let d4 = %sysfunc(putn("&sysdate9"d ,mmddyyp10.));
%let d5 = %sysfunc(putn('01Jan2008'd ,weekdate.));

%put d1= &d1;
%put d2= &d2;
%put d3= &d3;
%put d4= &d4;
%put d5= &d5;
[/pre]

cynthia
deleted_user
Not applicable
Hihi,

just tried but sas still assign some other number to the date..
Cynthia_sas
SAS Super FREQ
Hi:
&SYSDATE may not be the same date as TODAY(). Especially if your version of SAS is on a server that is not taken down often. Usually &SYSDATE is the date that the SAS session started...while TODAY() returns a value from the computer's "calendar/clock" functions.

Are you saying that today() does not return today's date????

[pre]
%let x = %sysfunc(today());
%let y = %sysfunc(today(),mmddyy10.);
[/pre]

If these statements do not produce the following results, then you should contact Tech Support for more help. (If you're on the other side of the international date line, of course, your date will be off from mine by a day.
[pre]
1 %let x = %sysfunc(today());
2 %let y = %sysfunc(today(),mmddyy10.);
3
4 %put *******x=&x y=&y;
*******x=17764 y=08/20/2008

[/pre]

Today's date in as a SAS number is 17764. With the mmddyy10. format applied, the macro variable &Y has a value of 08/20/2008.

cynthia
deleted_user
Not applicable
Hi..

I manage to get it already! Thanks so much for everybody's help.
\(^o^)/

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2919 views
  • 1 like
  • 3 in conversation