DATA Step, Macro, Functions and more

Reading Time variable from Excel

Reply
Contributor
Posts: 23

Reading Time variable from Excel

[ Edited ]

Hi

I have a column in excel, variable : Time with HH:MM

 

I am trying to import in SAS, but my Time variable gives 0.333333....

 

I am trying to convert it :

 

DATA NT;

SET NT;

Time = input(Time, time5.);

FORMAT Time time5.;

RUN;

 

I have a new blank column Time in SAS.

 

Thanks for you answers !

 

 

Super User
Posts: 22,850

Re: Time

Don't use the same data set name in your DATA and SET statement, it makes it really hard to trace your errors. 

 

Can you show what your data looks like before you did your conversion?

Contributor
Posts: 23

Re: Time

Time

Contributor
Posts: 23

Re: Time

Time:  8:00 8:15 8:30 ... 18:00 in Excel

 

 

 

 

Super User
Posts: 22,850

Re: Time

What did it look like when you imported the data into SAS?

What was the type and format of the variable?

 

Did you try applying a format rather than doing a conversion?

 

 

Contributor
Posts: 23

Re: Time

Thanks for your help.

problem is solved

Contributor
Posts: 23

Re: Time

PROC IMPORT DATAFILE="\\........\Name.xlsx"

DBMS=xlsx REPLACE OUT=NT;

SHEET='NT';

GETNAMES=YES;

FORMAT Time time5.;

RUN;

 

Ok now...

PROC Star
Posts: 1,190

Re: Reading Time variable from Excel

Ask a Question
Discussion stats
  • 7 replies
  • 143 views
  • 0 likes
  • 3 in conversation