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;
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 save with the early bird rate—just $795!