06-02-2017 08:31 AM
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;
06-02-2017 08:40 AM
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.
06-02-2017 09:03 AM
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.
06-02-2017 09:15 AM
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?
06-02-2017 09:19 AM
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
Need further help from the community? Please ask a new question.