DATA Step, Macro, Functions and more

88/88/8888 mmddyy10. format

Reply
Frequent Contributor
Posts: 104

88/88/8888 mmddyy10. format

For the SAS date format mmddyy10., the date January 25, 2013 would be written as "25Jan2013"d.

Applying this format, how would 88/88/8888 be written?  If this format cannot be used, what other format is advised in order for SAS to recognize 88/88/8888 as a valid date?

Thanks!

Super Contributor
Posts: 543

Re: 88/88/8888 mmddyy10. format

88/88/8888 is not a valid date...

Could you provide more context?

Smiley Happy

Super Contributor
Posts: 578

Re: 88/88/8888 mmddyy10. format

Also, I believe the mmddyy10. format looks like 01/25/2013 without the quotes and the d.

Super User
Posts: 10,483

Re: 88/88/8888 mmddyy10. format

What date system are you using that has 88 as either month or day of month (or equivalent)? The NLS system option LOCALE controls the defaults of how dates may be structured and may have some bearing but more details would help.

Super User
Super User
Posts: 6,498

Re: 88/88/8888 mmddyy10. format

For SAS to recognize strings like 'xx/xx/xxxx' as dates you would need an INFORMAT, not a FORMAT.

You would use MMDDYY10. if the first part is the month and DDMMYY10. if the first part is the day.

data test;

  str='01/01/1960';

  dt = input(str,mmddyy10.);

  format dt date9.;

  put (_all_) (=);

run;

str=01/01/1960 dt=01JAN1960

Valued Guide
Posts: 2,174

Re: 88/88/8888 mmddyy10. format

sophia_SAS wrote:

For the SAS date format mmddyy10., the date January 25, 2013 would be written as "25Jan2013"d.

Applying this format, how would 88/88/8888 be written?  If this format cannot be used, what other format is advised in order for SAS to recognize 88/88/8888 as a valid date?

Thanks!

SAS won't recognise 88/88/8888 as a date, but you can make it appear so.

It uses a facility I call "embedded formats".

A special value would be stored for the 88 date, and a special informat and format would read it and re-present it with what-ever layout you want.

Here is the construction of the special formats - I'll call them informat and format    d88d.

proc format ;

   invalue d88d

           '88/88/8888' = 8e8 /* special non-date value */

            other = [mmddyy14.]

        ;

* here is a special format to write the 88 dates among normal dates ;

   value d88d

         8e8  = '88/88/8888'

        other = [mmddyy10.]

      ;

run ;

%put %sysfunc( today(), d88d ) ;

%put %sysfunc( inputn( %str(88/88/8888), d88d ), d8d) ;

%put %sysfunc( inputn( %str(26/01/2013), d88d ), d8d) ;

Frequent Contributor
Posts: 127

Re: 88/88/8888 mmddyy10. format

Hi,

Here is an example with three different date formats adding a slash as separator in between the year, month and day values (this is achived by the 's' after the date format. It may also be a blank, colon, dash, period or no separator):

data want;

  date='25JAN2013'd;

  date1 = put(date, ddmmyys10.);

  date2 = put(date, mmddyys10.);

  date2 = put(date, yymmdds10.);

run;

Regards,

Florent

Ask a Question
Discussion stats
  • 6 replies
  • 8375 views
  • 4 likes
  • 7 in conversation