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

Hi Everyone,

 

I'm trying to import excel file using SAS Data Integration studio, that have 3 different columns with DateTime format. Among those 3 col's only 2 columns are reading in correct format other column is reading is as Character due to empty rows. 

 

Sample data : 

 

Date1                              Date2                               Date3
Jan 11, 2019 12:17 PM        Jan 18, 2019 1:00 PM             
Jan 18, 2019 1:00 PM          Jan 11, 2019 9:23 PM            Jan 1, 2019 9:23 PM
Jan 11, 2019 12:17 PM        Jan 18, 2019 1:00 PM


Date 1 and Date2 are reading in correctly without any issues 

 

But Date3 reads in as 43486.40625.

 

Can anyone suggest what to do to get it correct.

1 ACCEPTED SOLUTION
5 REPLIES 5
ashna
Obsidian | Level 7

Nope, I don't have any strings in the column.

As mentioned before, few of the cells or observations in this column are empty.

andreas_lds
Jade | Level 19
Abandoning excel as data source is not an option? Such problems always arise, because excel is one of the worst file-formats for data storage. Excel lacks clear type definitions for columns, makeing it difficult for sas to guess the right type.

Check the column: has any cell a type other than date?
ChrisNZ
Tourmaline | Level 20

1. You must have data in the third column. Even spaces are characters and can trigger reading the field as a character.

 

data t; 
  X=put(datetime(),datetime20.);output;
  X=' ';                        output;
run;
proc export data=t outfile="%sysfunc(pathname(WORK))\t.xlsx" dbms=xlsx replace; run;
proc import out=r datafile="%sysfunc(pathname(WORK))\t.xlsx" dbms=xlsx replace; run;

 

2. The value you are showing (is it a character?) is a valid excel date time.

 

data T; 
  EXCELDATE=43486.40625; 

  SASDATE=intnx('year',EXCELDATE,-60);
  put SASDATE date9.; 

  SASTIME= (EXCELDATE-int(EXCELDATE)) *60*60*24;
  put SASTIME= time.; 
run;

SASDATE=01JAN2019
SASTIME=9:45:00

3. Did you try option DBSASTYPE ?

 

 

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 5 replies
  • 6707 views
  • 0 likes
  • 4 in conversation