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

Hi,

 

I have used proc import a time variable from Xlsx and it turns into a character variable. 

For example 

In xlsx

Occ_Time
9/22/2016 9:00
9/22/2016 9:00
9/22/2016 9:00
9/22/2016 9:00
9/22/2016 12:00

 

After proc import. The variable becomes Character and the value are

Occ_Time 

42635.375
42635.375
42635.375
42635.375
42635.5

 

I need to learn how to correct it in my SAS data set.

Thank you.

 

1 ACCEPTED SOLUTION

Accepted Solutions
CHL0320
Obsidian | Level 7

Thank you all for your help. I have found an article and be also to convert Excel date to SAS date and then present it in a format of datetime16. 

In brief, 

SAS_date_time=(Excel_date_time-21916)*86400.

 

Here is that article.

 https://support.sas.com/resources/papers/proceedings/proceedings/sugi29/068-29.pdf

View solution in original post

3 REPLIES 3
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

date_wanted = datepart(Occ_time);

ChrisNZ
Tourmaline | Level 20

Like this?

data tr;
  XLS_DATE=42635.375; 
  SAS_DATE=intnx('year',int(XLS_DATE),-60,'s')-1;
  putlog SAS_DATE= date9.;
run;

SAS_DATE=22SEP2016

SAS dates start on 01JAN1960, Excel dates start on 01JAN1900.

 

CHL0320
Obsidian | Level 7

Thank you all for your help. I have found an article and be also to convert Excel date to SAS date and then present it in a format of datetime16. 

In brief, 

SAS_date_time=(Excel_date_time-21916)*86400.

 

Here is that article.

 https://support.sas.com/resources/papers/proceedings/proceedings/sugi29/068-29.pdf

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 828 views
  • 1 like
  • 3 in conversation