Help using Base SAS procedures

DT- formats

Reply
Valued Guide
Posts: 2,177

DT- formats

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
Super Contributor
Posts: 359

Re: DT- formats

Isn't that what the EURDFDTw.d Format does?
Valued Guide
Posts: 2,177

Re: DT- formats

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
Super Contributor
Super Contributor
Posts: 3,174

Re: DT- formats

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
Valued Guide
Posts: 2,177

Re: DT- formats

fine, but I wanted ddmmyy, for which I found no format tolerating datetime values.
Is there one I missed?

PeterC
Super Contributor
Super Contributor
Posts: 3,174

Re: DT- formats

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.
Valued Guide
Posts: 2,177

Re: DT- formats

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).
Super Contributor
Super Contributor
Posts: 3,174

Re: DT- formats

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.
Ask a Question
Discussion stats
  • 7 replies
  • 208 views
  • 0 likes
  • 3 in conversation