BookmarkSubscribeRSS Feed
oht
Calcite | Level 5 oht
Calcite | Level 5

Is there a quick date time format that can convert datatime(today()) into mmddyyyyhhmmss without any colon or space ? Thanks


2 REPLIES 2
CTorres
Quartz | Level 8

Try this

data want ;

  format a datetime19.0 b z14.;

  input a datetime.;

  b=input(put(datepart(a),mmddyyn8.)||compress(substr(put(a,datetime19.0),12),':'),14.);

  cards;

25jan2013:08:30:55

01jan2013:23:59:59

31dec2012:00:00:00

;

run;

hdodson_pacificmetrics_com
Calcite | Level 5

oht,

     I don't know of any format supplied out-of-the-box that does what you require. But you can make your own format:

proc format;
      /*Decimal points disabled*/
      PICTURE date_smash_up_a
            low-high = '%0d%0m%Y%0H%0M%0S' (DATATYPE=datetime);


      /*Decimal points enabled*/
      PICTURE date_smash_up_b
            low-high = '%0d%0m%Y%0H%0M%0s' (DATATYPE=datetime);
run;

data _null_;
     now = datetime();
     put "datetime18.   : " now datetime18.;
     put "date_smash_up_a18.  : " now date_smash_up_a18.;
     put "date_smash_up_b22.3 : " now date_smash_up_b22.3;
run;

The zero in "...%0M...", for example, inserts leading zeros into the month number when applicable.

Hope this helps,

Huey

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 854 views
  • 0 likes
  • 3 in conversation