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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 614 views
  • 1 like
  • 3 in conversation