BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SASdevAnneMarie
Barite | Level 11

Hello Experts,

 

I would like to display my data as 2025100513 (yyyymmddtt). My code seems do not work and I can not find the right format here : SAS Help Center: Working with Dates and Times By Using the ISO 8601 Basic and Extended Notations.

I have this error message :  ERROR: Format name B8601DT10.0 not found or the width and/or decimal specified for the format used are out of range. Thank you for your help.

This my code :

%let Ma_Date=%sysfunc(compress(%sysfunc(datetime(),B8601DT10.0),T));

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@SASdevAnneMarie wrote:

Hello Experts,

 

I would like to display my data as 2025100513 (yyyymmddtt). My code seems do not work and I can not find the right format here : SAS Help Center: Working with Dates and Times By Using the ISO 8601 Basic and Extended Notations.

I have this error message :  ERROR: Format name B8601DT10.0 not found or the width and/or decimal specified for the format used are out of range. Thank you for your help.

This my code :

%let Ma_Date=%sysfunc(compress(%sysfunc(datetime(),B8601DT10.0),T));

 


It is telling you that the format you have chosen is not wide enough. B8501DT must have a width of between 15 and 26. So this works:

 

%let Ma_Date=%sysfunc(putn(%sysfunc(datetime()),B8601DT15.0));
%put &=ma_date;

 

If you don't want the minutes and seconds in the output, you can use the %substr function to chop off the last 4 unwanted digits.

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

@SASdevAnneMarie wrote:

Hello Experts,

 

I would like to display my data as 2025100513 (yyyymmddtt). My code seems do not work and I can not find the right format here : SAS Help Center: Working with Dates and Times By Using the ISO 8601 Basic and Extended Notations.

I have this error message :  ERROR: Format name B8601DT10.0 not found or the width and/or decimal specified for the format used are out of range. Thank you for your help.

This my code :

%let Ma_Date=%sysfunc(compress(%sysfunc(datetime(),B8601DT10.0),T));

 


It is telling you that the format you have chosen is not wide enough. B8501DT must have a width of between 15 and 26. So this works:

 

%let Ma_Date=%sysfunc(putn(%sysfunc(datetime()),B8601DT15.0));
%put &=ma_date;

 

If you don't want the minutes and seconds in the output, you can use the %substr function to chop off the last 4 unwanted digits.

--
Paige Miller
SASdevAnneMarie
Barite | Level 11
Thank you !
Kurt_Bremser
Super User

Maxim 1: Read the Documentation.

B8601DTw.d Format :

w

specifies the width of the output field.

Default 19
Range 15–26

 

So you can't use this format with a length of 10.

Roll your own custom format with PROC FORMAT:

proc format;
picture ymdh 
  low-high = '%Y%0m%0d%0H' (datatype=datetime)
;
run;

data _null_;
x = datetime();
put x= ymdh10.;
run;
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 384 views
  • 5 likes
  • 3 in conversation