Suppose I have a dataset like this. The date is in character format. I need to convert it into date format and choose only current month data from the below dataset. It should be dynamic. Also I need another dataset where I need previous month data only. This also needs dynamic. I could have chosen month(transmonth)= current month but I need year also. Please help
data one ; input obs id jobcat $ transmonth $11. ; datalines; 1 1254 one 29AUG2019 2 9936 two 19AUG2019 3 7529 two 01AUG2019 4 9154 one 03AUG2019 5 7741 two 18JUL2019 6 8896 two 11JUL2019
data current_monthyear prevmonth_curr_year;
set one;
numeric_date=input(transmonth,date9.);
if put(today(),monyy7.)=put(numeric_date,monyy7.) then output current_monthyear;
else if put(intnx('mon',today(),-1),monyy7.)=put(numeric_date,monyy7.) then output prevmonth_curr_year;
format numeric_date date9.;
run;
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!