BookmarkSubscribeRSS Feed
Peter_C
Rhodochrosite | Level 12
A convenient collection of formats provided by SAS are
dtDate
dtMonYY
dtYYqC
dtWkDatX
These correspond to formats Date, MonYY, YYqC and WeekDatX, but work on DateTime values rather than Date values.
These formats are very convenient for displaying dates provided through SAS/Access routines ~ because typically these data access modules create dateTime values ~ and these formatsneed no datepart() conversion.
Here in UK, date layout standards would like a format DTDDMMYY for dates loaded through SAS/Access, but the format does not exist..... until I create it with [pre]proc format ;
picture dtddmmyy
'1jan1582:0:0'dt - '31DEC9999:23:59:59.99'dt
= '%0d/%0m/%0Y'(DATATYPE=DATETIME)
;
run ;[/pre]Of course, this format must be able to be found through the FMTSEARCH paths.

Before I start building user infrastructure to standardise support for this simple National Language standard, is there any prospect of the list of DT-formats being expanded to support the wider range of date display styles expected of, and built-in to SAS?

PeterC
7 REPLIES 7
Flip
Fluorite | Level 6
Isn't that what the EURDFDTw.d Format does?
Peter_C
Rhodochrosite | Level 12
Flip
nope.
as declared in the alphabetical list of formats [pre]EURDFDTw.d Format EURDFDT w.d
Writes international datetime values in the form ddmmmyy:hh:mm:ss.ss or ddmmmyyyy hh:mm:ss.ss. [/pre] subject to the LOCALE= value (and probably not just european)
I was seeking a format that took a datetime value and returned the datepart in more formats than the limited set offered by the DT-formats group. That group are helpful as all databases, that I have come across, return dates to SAS as datetime values and I don't need to provide screen space for a timepart full of zeroes.
In particular I like the ddmmyy format, so wanted a DTddmmyy. It is easy to create but pointless to build the administrative support required among a group of users sharing the data on which they work. So I was asking if SAS might be planning a hotfix providing more dt-type date formats. Recent expansion of formats does seem to be heading in different directions.


PeterC
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You specify a length attribute "w" so that only the date-portion is exposed.

Scott Barry
SBBWorks, Inc.

1 data _null_;
2 format my_date EURDFDT9.;
3 my_date = datetime();
4 putlog _all_;
5 run;

my_date=14DEC2009 _ERROR_=0 _N_=1
NOTE: DATA statement used (Total process time):
real time 0.06 seconds
cpu time 0.01 seconds
Peter_C
Rhodochrosite | Level 12
fine, but I wanted ddmmyy, for which I found no format tolerating datetime values.
Is there one I missed?

PeterC
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
My apology for overlooking this particular detail. You will want to contact SAS tech support directly with your inquiry request for a new "datetime" format, however in the meantime you will likely need to move forward to create your own permanent SAS format for this purpose (make it fairly unique named for easy identification).

Scott Barry
SBBWorks, Inc.
Peter_C
Rhodochrosite | Level 12
scott,
the user-defined format works.
did you think my suggested name DTddmmyy unsuitable ?
I'm more concerned about providing the shared foundation (in the absence of a bi server).
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Definitely not unreasonable - I have supported UK-based companies who use SAS and they typically display/print only date and sometimes the time-portion but as separate columns, rather than combined.

Of course your other choice is to concatenate the two components at display time, creating a character-type variable in the desired format.

Concerning your site's SAS shared foundation - I take that to mean a SAS enterprise environment master CATALOG OBJECT library,where you store various site-unique SAS-related items, such as FORMATs (either display or look-up), possibly INFORMATs, ODS templates, and other tables. Suggest you set this up centrally and provide either a user-invoked macro to concatenate your local OBJECT using a LIBNAME . Look at using the GETOPTION function to retrieve the current FMTSEARCH and conditionally replace it, if necessary.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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