I have character date in YYMM format.(Column Name EXPDATE)
e.g. '2004' which means April 2020
'2104' which means April 2021
'2204' which means April 2022
'2304' which means April 2023
How to convert it into date format ?
Being a beginner in SAS I googled the same and use below mentioned logic
format exp date9.;
Exp = intnx('month', input(put(EXPDATE,4.), yymmn4.), 1)-1;
Which gives me output 30Apr1920 instead of 2020 and similarly for all remaining values where YY value is above 20.
Please help me to resolve the same.
Business Analyst,HDFC Bank
Your problem is YEARCUTOFF I expect it is the same as mine which defaults to 1920 set it to something greater than your largest 2 digit year; Also you don't need PUT(EXPDATE,4.) as EXPDATE is already character, or so you say. If you want the last day of the month EXP you can advance by 0 and use E for the alignment option. This it looks like you know how INTNX works.
Note sure why you are getting the wrong century, but it is not hard to add the century back in. Is the existing variable character or numeric? You text says it is character but your example code is treating it as numeric. If it is numeric then convert it to text using the Z4. format to preserve any leading zeros.
input text_date $4.;
format num_date: yymmdd10.;
put (_all_) (=);
text_date=2004 num_date1=2020-04-01 num_date2=2020-04-01 num_date3=2020-04-01 num_date4=2020-04-01
text_date=2104 num_date1=2021-04-01 num_date2=2021-04-01 num_date3=2021-04-01 num_date4=2021-04-01
text_date=2204 num_date1=2022-04-01 num_date2=2022-04-01 num_date3=2022-04-01 num_date4=2022-04-01
text_date=2304 num_date1=2023-04-01 num_date2=2023-04-01 num_date3=2023-04-01 num_date4=2023-04-01
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.