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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

data want (drop=in_:);

  set have (rename=GPS_Time=in_time);

   format GPS_Time time10.;

GPS_Time = input(in_time,time10.);

run;

View solution in original post

6 REPLIES 6
data_null__
Jade | Level 19

Read the variable with TIME10. informat.

time = input(xltime,time10.);

iiibbb
Quartz | Level 8

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.

Tom
Super User Tom
Super User

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

iiibbb
Quartz | Level 8

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

art297
Opal | Level 21

data want (drop=in_:);

  set have (rename=GPS_Time=in_time);

   format GPS_Time time10.;

GPS_Time = input(in_time,time10.);

run;

iiibbb
Quartz | Level 8

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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