data dates_format;
input id dates anydtdte32.;
format dates date9. month_year mmyyyy.;
month_year=substr(dates,3);
datalines;
1 10/1/2022
2 23march2023
3 11-feb-2022
;
run;
Hi guys ,
how to get month and year from different date formats
requiered output:
jan2022
march2023
feb2022
You have assigned a format that you don't want to use for variable DATES. You don't want it as format DATE9. you want it as format MONYY7.
data dates_format;
input id dates anydtdte32.;
format dates monyy7.;
datalines;
1 10/1/2022
2 23march2023
3 11-feb-2022
;
run;
Use the MONYY7. Format
data dates_format;
input id dates anydtdte32.;
format dates monyy7.;
datalines;
1 10/1/2022
2 23march2023
3 11-feb-2022
;
run;
Thank you peter
for you solution
You have assigned a format that you don't want to use for variable DATES. You don't want it as format DATE9. you want it as format MONYY7.
data dates_format;
input id dates anydtdte32.;
format dates monyy7.;
datalines;
1 10/1/2022
2 23march2023
3 11-feb-2022
;
run;
Thank you Miller
if we want extract date and month the which format
@BrahmanandaRao wrote:
if we want extract date and month the which format
what would it look like?
data dates_format;
input id dates anydtdte32.;
format dates date9. dates DATE5.;
datalines;
1 10/1/2022
2 23march2023
3 11-feb-2022
;
run;
date and month
@BrahmanandaRao wrote:date and month
I asked "What would it look like?", you haven't shown us what the desired output would look like. Show us.
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.