hello,
I have date format yymmn6. I want to change it to MMDDYY10.
by adding the last day of the month
have : 198605
want 05/31/1986
thanks
@dexcort2020 wrote:
If it is already a date, then this does it:
2022 var mmddyy10.; var = intnx('month',var,0,'e');
If it is a string, do this:
numdate = intnx('month',input(chardate,yymmn6.),0,'e'); 2022 numdate mmddyy10.;
2022 is not a valid SAS statement.
Is the variable in question already a SAS date with a format of YYMMN6., or is it a character variable containing the string?
If it is already a date, then this does it:
format var mmddyy10.;
var = intnx('month',var,0,'e');
If it is a string, do this:
numdate = intnx('month',input(chardate,yymmn6.),0,'e');
format numdate mmddyy10.;
If it is already a date, then this does it:
2022 var mmddyy10.;
var = intnx('month',var,0,'e');
If it is a string, do this:
numdate = intnx('month',input(chardate,yymmn6.),0,'e');
2022 numdate mmddyy10.;
@dexcort2020 wrote:
If it is already a date, then this does it:
2022 var mmddyy10.; var = intnx('month',var,0,'e');
If it is a string, do this:
numdate = intnx('month',input(chardate,yymmn6.),0,'e'); 2022 numdate mmddyy10.;
2022 is not a valid SAS statement.
And if the original variable is numeric with values like 202,201 which humans might see as meaning January 2022 then you need add another layer to the function call sandwich.
So pick the proper second statement based on whether VAR is
1) date valued numeric
2) character
3) regular integer valued numeric.
format want mmddyy10.;
want = intnx('month',var,0,'e');
want = intnx('month',input(var,yymmn6.),0,'e');
want = intnx('month',input(put(var,z6.),yymmn6.),0,'e');
hello,
I have date format yymmn6. I want to change it to MMDDYY10.
by adding the last day of the month
have : 198605
want 05/31/1986
thanks
DUPLICATE THREAD
Do not reply here
Reply at https://communities.sas.com/t5/SAS-Programming/add-day-to-format-date/m-p/806467#M317742
Please reconsider which of the posts you mark as a solution. My correction of @dexcort2020 's post is not a solution for your initial question.
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.