BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
OzanKirtac
Fluorite | Level 6

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

 

Screenshot_2.png

1 ACCEPTED SOLUTION

Accepted Solutions
maguiremq
SAS Super FREQ

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.

View solution in original post

4 REPLIES 4
maguiremq
SAS Super FREQ

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

 

OzanKirtac
Fluorite | Level 6

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?

maguiremq
SAS Super FREQ

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.

OzanKirtac
Fluorite | Level 6

thank you! cheers!

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

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
  • 4 replies
  • 790 views
  • 2 likes
  • 2 in conversation