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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 628 views
  • 1 like
  • 2 in conversation