I need to use SAS to input a string containing a time value, expressed as the number of milliseconds since the Unix epoch.
E.g., I have an input string of "1278486000000" and I want to extract the date value "2010-07-07".
Basically, I need the SAS informat version of this online tool.
It's a fairly common timestamp, so I guess there's an inbuilt SAS format for this. I know about the difference between SAS' 1960 epoch and the standard Unix 1970 epoch however, so I'm supposing that might complicate matters.
If there is no standard informat, how would I go about creating one?
I don't know about an informat, but this is certainly doable with a function call.
data _null_;
x="1278486000000";
y=datepart(intnx('dtyear',input(x,best32.)/1000,10,'s'));
put y= date.;
run;
We pretend it's a 1960 epoch and then adjust to a 1970 epoch. This will be slightly off of your answer, because your answer is adjusted for timezone. You can adjust the SAS value for timezone as well, separately, if you wish.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With