BookmarkSubscribeRSS Feed
sophia_SAS
Obsidian | Level 7

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!

6 REPLIES 6
AncaTilea
Pyrite | Level 9

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

Could you provide more context?

Smiley Happy

DBailey
Lapis Lazuli | Level 10

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

ballardw
Super User

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.

Tom
Super User Tom
Super User

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

Peter_C
Rhodochrosite | Level 12

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) ;

Florent
Quartz | Level 8

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

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
  • 6 replies
  • 16454 views
  • 4 likes
  • 7 in conversation