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!
88/88/8888 is not a valid date...
Could you provide more context?
Also, I believe the mmddyy10. format looks like 01/25/2013 without the quotes and the d.
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.
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
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) ;
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.