Hi
I hope some one can help me.
There is a wrong date in the original database. I don't want to go back to the original database.
I have searched on it in google and at this website and found NO ANSWER.
https://communities.sas.com/t5/Base-SAS-Programming/how-to-convert-char-var-to-sas-date/td-p/45067
Now, here is what the contents of the dataset say for that variable.
| woundvstdate | Num | 8 | MMDDYY8 |
My code is:
data initial;
set aung.initialdat_mg2;
if id=55 then woundvstdate=04/20/10;
proc print;
run;
My outpout is:
| 55 | 01/01/60 |
Obviously, that is wrong.
I know there more wrong dates and don't want to keep going back to the original dataset.
I know this will happen in future endeavors.
Is there a way to do this in a datastep?
thank you!
@mgrzyb wrote:
There is a wrong date in the original database. I don't want to go back to the original database.
...
My code is:
data initial;
set aung.initialdat_mg2;
if id=55 then woundvstdate=04/20/10;
When you type 04/20/10, it is division. You are dividing 04 by 20 and then dividing by 10.
To indicate that 04/20/10 is a date value, use
if id=55 then woundvstdate='20APR10'D;
@mgrzyb wrote:
There is a wrong date in the original database. I don't want to go back to the original database.
...
My code is:
data initial;
set aung.initialdat_mg2;
if id=55 then woundvstdate=04/20/10;
When you type 04/20/10, it is division. You are dividing 04 by 20 and then dividing by 10.
To indicate that 04/20/10 is a date value, use
if id=55 then woundvstdate='20APR10'D;
Thankyou!
That worked. I also tried this, and it seemed to work after I checked out proc contents again.
If there is a difference between the 2, please let know.
if id=55 then put=(woundvstdate=04/20/10);
Thank you again!!!!
PROC CONTENTS would not contain information about whether or not changing the value of a variable was successful or not.
if id=55 then put=(woundvstdate=04/20/10);
I don't see how this code would successfully change the value of a variable either.
The bottom line is you have to LOOK at the data set with your own eyes, and see if the value is correct in the data set or not. PROC CONTENTS, and PUT statements don't suffice.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.