Help using Base SAS procedures

Some help importing some time data.

Accepted Solution Solved
Reply
Contributor
Posts: 41
Accepted Solution

Some help importing some time data.

I am trying to import a GIS field that contains time data.  SAS is

importing it from Excel as a character string, but I need to convert it to a time

string.  I can 't seem to figure out how.

Examples of the field is

10:12:56am

11:23:23am

12:43:23pm

03:45:21pm

05:23:53pm

I am a little befuddled.


Accepted Solutions
Solution
‎02-08-2012 07:30 PM
PROC Star
Posts: 7,364

Re: Some help importing some time data.

data want (drop=in_Smiley Happy;

  set have (rename=GPS_Time=in_time);

   format GPS_Time time10.;

GPS_Time = input(in_time,time10.);

run;

View solution in original post


All Replies
Respected Advisor
Posts: 3,777

Some help importing some time data.

Read the variable with TIME10. informat.

time = input(xltime,time10.);

Contributor
Posts: 41

Re: Some help importing some time data.

Explain further...

if I import the data using the import data menu, and create a permanent dataset in a library.

Then I create a temporary dataset and convert the variable using that formula?

It might help to note that Excel doesn't recognize it as a time field either.

Super User
Super User
Posts: 6,502

Re: Some help importing some time data.

Import it as a temporary dataset and then use a data step to create the permanent dataset with the time variable converted.

Contributor
Posts: 41

Re: Some help importing some time data.

say the variable's name is GPS_Time.

Could you please give me an example of that syntax?

I tried adding it, but apparently I'm putting it in the wrong place.

Thank you

Solution
‎02-08-2012 07:30 PM
PROC Star
Posts: 7,364

Re: Some help importing some time data.

data want (drop=in_Smiley Happy;

  set have (rename=GPS_Time=in_time);

   format GPS_Time time10.;

GPS_Time = input(in_time,time10.);

run;

Contributor
Posts: 41

Re: Some help importing some time data.

Thank you.

Sometimes I wonder if I'm ever going to understand some of this syntax... but I've always had so much control over my data before moving to SAS and thus, my code has always been clean and simple.  This automated stuff is really making me realize how much I don't know.

Thanks

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 158 views
  • 0 likes
  • 4 in conversation