BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mdsaraiv
Fluorite | Level 6

 

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;

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
kiranv_
Rhodochrosite | Level 12

Date literal should be in form of '02Dec2017'd

View solution in original post

6 REPLIES 6
gauthamk28
Obsidian | Level 7
Hope this works

if id=201 then enterdata="02/12/2011"d
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

mdsaraiv
Fluorite | Level 6

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. 

 

 

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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?

mdsaraiv
Fluorite | Level 6

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

kiranv_
Rhodochrosite | Level 12

Date literal should be in form of '02Dec2017'd

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1846 views
  • 2 likes
  • 4 in conversation