BookmarkSubscribeRSS Feed
Ps8813
Fluorite | Level 6

I have 1 time in excel file it's value is 27:27.36  i.e. 27 min 27 sec 36 subsec

What informat need to be used to read this value. I need informat so that i can read this value.

I used time10.2 and few other informat but it is not working.

 

Thanks in advance

2 REPLIES 2
Kurt_Bremser
Super User

The SAS informats expect hours, minutes, seconds and parts of seconds, so set a proper time format (including hours) in Excel before importing into SAS.

ballardw
Super User

HOW are you reading from Excel? Did you convert to CSV and read that?

 

Also describe how "it is not working". Do you get an error? so the error message.  no result or  Unexpected result? Show actual input and results.

 

Note: The SAS TIME informat is going to expect a time of day with an HOUR component.

If you do not havee an hour then you will need to bring the value in as text and then extract the minute and seconds component then use the HMS function to create a time value.

data junk;
   x='27:27.6';
   y = hms(0,scan(x,1,':'),scan(x,2,':'));
   format y time10.2;
run;

This will create a message about character to numeric conversions as the scan function returns character values and we are using them in a numeric role.

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 2 replies
  • 648 views
  • 0 likes
  • 3 in conversation