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 ?

 

 

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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