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

I have a data set "hvid11", imported from a RedCap database as excel originately.

I imported it and now one of my date variables (debutskopi_date) is defined as a character with values around 41000 in stead of a date.

My goal was to change is so the dates have the format "MM/DD/YYYY"

I tried to change it to a date variable using this code:

 

Data hvid11; set hvid11;

debutskopi_date2= input(debutskopi_date,anydtdte32.);

Format debutskopi_date2 ddmmyy10.;

Run;

 

But the output variabel debutskopi_date2 has wrong dates.

The years in the dates should be between 2013 and 2020, but is in stead between 1940 and 1944

 

Any suggestions will be greatly approciated.

 

Best regards Anne

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

You imported this from Excel, and because of some funny values in the column you got the raw Excel values as character. Do this:

debutskopi_date2= input(debutskopi_date,32.) + '30dec1899'd;

to correct for the different offset in SAS vs. Excel.

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

You imported this from Excel, and because of some funny values in the column you got the raw Excel values as character. Do this:

debutskopi_date2= input(debutskopi_date,32.) + '30dec1899'd;

to correct for the different offset in SAS vs. Excel.

AnneLK
Fluorite | Level 6
Brilliant!
Thank you 🙂
Best regards Anne

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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