I am having a problem correcting dates in my sas file. I already have all set sas files with dates DDMMYYYY (like 02/10/2011). Ok, but then I found that some of my dates (form some individuals) are incorrect and I want to correct it in a date step.
Lets supose I have the individual ID = 201 with a interview date (interdate) = 02/10/2011 but I want to correct this date to 02/12/2011.
I tried mane ways and I wasnt able to figure that out. I tried the date numbers between quota, with slash, with hifen....and so on. I also tried to format again the variable.
Does anybody can help me...? I will have to correct several dates. I don´t want to have to export to excell every time then correct there and then import again into SAS...
the original enterdata is correct in the format like 02/10/2011, and it is working ok, I already caculated age of individuals from their birth date and so on.
data old; se new;
if ind = 201 then enterdata = 02122011;
run;
Date literal should be in form of '02Dec2017'd
Is there a logical rule to this? You could as @gauthamk28 has shown use a date literal, however I really don't think that is what you will want to do for all ID with dates to change. So how do you know the date should be Dec rather than Oct? If you can provide a few lines of sample data in a datastep, and what the output should look like then we can provide example code.
We notice that the date was wrong because we have original patient's questionnaires and the date is actually wrong, so I need to change the date for some specific individuals because some one entered the wrong date.
So you have a list of the correct dates yes? If so then why not just merge that list on and where date1 ne date2 replace date1 with date2 - this would be the more sensible option from a data management and logical route rather than manually entering some data?
Thanks, but it is not in a list, I have to grab the original questionnaire and fix it, and I want the correction to be written in sas-editor as a register so that other people will know the date was wrong and now correct. The answer of adding quotas and "d" worked well.
Thanks so much for your help
Date literal should be in form of '02Dec2017'd
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.