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
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.
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.