BookmarkSubscribeRSS Feed
gzr2mz39
Quartz | Level 8
Hi,
How do I change the format of &sysdate from 14JUL10 to July 14, 2010 in the code below?

data _null_;
dcl odsout obj();
obj.table_start(name: "Date",
obj.row_start();
obj.format_cell(data: "Data updated &sysdate.",
obj.row_end();

Thank you.
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Create your own &MY_SYSDATE by using the &SYSDATE9 variable, converted to a SAS NUMERIC DATE, using INPUT, and follow that with a suitable PUT to re-format to your own date-variable value. Explore using %SYSFUNC(...) along with suitable SAS functions to do the data conversions, mentioned above.

Scott Barry
SBBWorks, Inc.
Peter_C
Rhodochrosite | Level 12
> Create your own &MY_SYSDATE by using the &SYSDATE9
> variable, converted to a SAS NUMERIC DATE, using
> INPUT, and follow that with a suitable PUT to
> re-format to your own date-variable value. Explore
> using %SYSFUNC(...) along with suitable SAS functions
> to do the data conversions, mentioned above.
>
> Scott Barry
> SBBWorks, Inc.

gzr2mz39

As Scott suggests - use %sysfunc()

The common route to reformat dates, uses the second parameter of %sysfunc() - a format for the results when the first parameter is a numeric function {like inputN() }

"Today" is much easier, than yesterday, which I would format like
%put yesterday was %sysfunc( intnx(day, "&sysdate9"d, -1), weekdate ) ;

The simpler equivalent for today (needing no intnx() function )
%put today is %sysfunc( putN("&sysdate9"d, weekdate ) ) ;
Alternatively, when using a SAS server which may have started before today (SAS session start time provides the underlying value in &sysdate and &sysdate9), use the today() function like
%put today is %sysfunc( today(), weekdate ) ;

When presenting timestamps, I like the SAS Title style :
%put now it is %sysfunc( datetime(), twmdy ) ;
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
I just noticed the OP is using a DATA step, so it's not necessary to use the character-string for &SYSDATE or &SYSDATE9 -- you can get the current date using one of several techniques, such as TODAY() function or a RETAIN SAS variable assigned to a constant "&SYSDATE9"D, and the use your DATA step variable to assign a date character-string in whatever format you choose, using a SAS output FORMAT. Given the code initially posted, no %SYSFUNC(...) is even needed.

Scott Barry
SBBWorks, Inc.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 5119 views
  • 0 likes
  • 3 in conversation