Hi,
I am trying to transform character imported timestamp variable to numeric timestamp variable so that I can change and play around with the variable. When I try to use input function, I keep getting errors.
The original timestap looks like the one below and I want to convert it to a format .
I run this code
data Z11; set Z10;
datadate = input(TIMESTAMP_UTC,8.);
format datadate YYMMDDN8.;
run;
then I keep getting errors:NOTE: Invalid argument to function INPUT at line 1015 column 12
All help is appreciated
No, you don't have to do the DATALINES statement. That was done for me to reproduce your issue and test whether my solution works. Just run the second chunk of code I provided:
data want;
set have;
datadate_nofmt = input(timestamp_utc, yymmdd10.);
datadate = put(input(timestamp_utc, yymmdd10.), yymmddn8.);
run;
You don't even have to do the 'datadate_nofmt' part. That was done just to show you what's going on.
Try this. I specified an INFORMAT to read in the date as numeric, and then I converted it to your desired FORMAT (yymmddn8).
data have;
input timestamp_utc $23.;
datalines;
2010-01-01 03:30:53.85
;
run;
data want;
set have;
datadate_nofmt = input(timestamp_utc, yymmdd10.);
datadate = put(input(timestamp_utc, yymmdd10.), yymmddn8.);
run;
timestamp_utc datadate_nofmt datadate 2010-01-01 03:30:53.85 18263 20100101
thank you for reply.
So will I have to inclued all timestamps in datalines? I have 53000 timestamps. Will I include all of them in the datalines?
No, you don't have to do the DATALINES statement. That was done for me to reproduce your issue and test whether my solution works. Just run the second chunk of code I provided:
data want;
set have;
datadate_nofmt = input(timestamp_utc, yymmdd10.);
datadate = put(input(timestamp_utc, yymmdd10.), yymmddn8.);
run;
You don't even have to do the 'datadate_nofmt' part. That was done just to show you what's going on.
thank you! cheers!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.