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