samrat
samrat

Reputation: 43

Convert Timestamp to Numeric value in SAS

How to convert the default timestamp "0001-01-01-00.00.00.000000" in SAS, i have tried below code but it has returned null value. Can someone help on this please

data _NULL_;

x = "0001-01-01-00.00.00.000000";

rlstime = input(x,anydtdtm26.);

call symput('rlstime',rlstime);

run;

%put rlst: &rlstime;

Upvotes: 1

Views: 422

Answers (2)

Dev.T
Dev.T

Reputation: 1

The earliest date that SAS will handle is 1st January, 1582. Additionally, a colon character should be used to delimit the time from the date, as well as the hours, minutes and seconds. Therefore, your code may be adjusted to the following:

data _NULL_;
  x = "1582-01-01:00:00:00.000000";
  rlstime = input(x,anydtdtm26.);
  call symput('rlstime',rlstime);
run;
%put rlst: &rlstime;

Upvotes: 0

Shalltear Bloodfallen
Shalltear Bloodfallen

Reputation: 29

As far as I remember, SAS cannot do that. Any date/timestamp before 1.1.1600 doesn't exist for SAS. Do you need it or can you just replace it with a null value? If you really need it you could transform it into another valid timestamp, split it into different columns (year, month, etc.) or just use it as a string. In your example you just write the timestamp into the log, meaning it's not necessary to transform it.

Upvotes: 1

Related Questions