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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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