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-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!

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