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

 

Hi SAS Community!

 

Problem:

1) I have multiple Excel files each containing date variables

2) All dates have General format in Excel because the date variables have a mixture of valid dates and acronyms

3) The date variable from one file out of 16 reads in incorrectly. I went back in Excel and specifically formatted the date variable in the problem file as 'date mm/dd/yyyy' but nothing changed.

 

             Excel                             Reads into SAS before applying an  informat/format                      PROC CONTENTS

File 1) 01/15/2013                               15JAN2013                                                                          datevar   Num  DATE9.

File 2) 01/01/2013                                  41275                                                                                datevar  Char  $5.

 

The value 41275 is way more than the calculated number of days since Jan 1, 1960 [19359]. I have no idea what units this is in to begin to figure out next steps . 

 

Using an informat (DATE9. or MMDDYY10.) isn't appropriate nor is just using a format alone. There must be a step in between. What am I missing?

 

Data want;

Set have;

  datevarN = input(datevar, X.);  

format datevarN X.;

run;

LOG- NOTE: Invalid argument to INPUT function at the line #

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

41275 is a Microsoft Office date value, which is the number of days since 01JAN1900 plus two (don't ask).

 

So,  SASdate = MSOdate + '01JAN1900'd - 2;

PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

41275 is a Microsoft Office date value, which is the number of days since 01JAN1900 plus two (don't ask).

 

So,  SASdate = MSOdate + '01JAN1900'd - 2;

PG
eap
Obsidian | Level 7 eap
Obsidian | Level 7

A big thank you to you! I would have never figured this out!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 2178 views
  • 1 like
  • 2 in conversation