BookmarkSubscribeRSS Feed
AdarshSaukat
Calcite | Level 5

Hi,

I need the timestamp in the below format:

2014-09-08-21.45.08.520676

The data part can be obtained by using the data functions and the time using time functions. But i am unable to get the microseconds.

Can someone help me out here with this.

Thanks in advance.

5 REPLIES 5
jakarman
Barite | Level 11

That is no time it is datetime in SAS words. The timestap is probably coming from a DBMS or OS conventions.

The datetime in SAS are integers measured in seconds fraction of seconds are you microseconds.

Do you want that as string printed out use Formats: SAS(R) 9.4 Formats and Informats: Reference

Do you want to have a conversion, let the conversion do the work.

What is your problem?

---->-- ja karman --<-----
Ksharp
Super User

TimeW.D can display decimal .

data have;
input time stimer12.;
format time time12.2;
cards;
09:02:12
05:04:19.21
;
run;

Xia Keshan

OS2Rules
Obsidian | Level 7

Hi:

I use a custom date time format like this:

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

***************************************************************************************;

data stuff;

a=datetime();

put a 22.2 +5 a mydtss.;

run;

Gives me:               1727341907.42        2014-09-26-09.11.47

You may need to play with it a bit to get all the decimal places for the seconds.

BrunoMueller
SAS Super FREQ

As stated before there is the datetime value in SAS.

See Log from SAS program

39         %put NOTE: &=sysvlong &=sysscpl %sysfunc(datetime(), 20.6);

NOTE: SYSVLONG=9.04.01M2P072314 SYSSCPL=X64_7PRO    1727371518.875000

As you see running on windows you get down to milliseconds but not more, might be different on Unix/Linux, can not test now

Bruno

Message was edited by: Bruno Müller

result from running in the SAS University Edition

41 %put NOTE: &=sysvlong &=sysscpl %sysfunc(datetime(), 20.8);

NOTE: SYSVLONG=9.04.01M1P120413 SYSSCPL=Linux 1727351691.72906000

jdmarino
Fluorite | Level 6

You may find this thread useful.  Based on my experiments, I would use datetimes if I did not need precisions higher than milliseconds.  If you need microseconds, I would separate the date part from the time part, which essentially gives you 16 bytes (8 for date [more than you need] + 8 for time [precision to nanoseconds, if you need it]).

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 4005 views
  • 0 likes
  • 6 in conversation