Hi @mauri0623
As mentioned by @Tom, the INTNX() is the function you need.
You can try this:
data want;
Invoice_date = "20190114";
date = compress(put(intnx("day",(intnx("month",input(Invoice_date,YYMMDD10.),-1)),27),YYMMDD10.),"-");
run;
Several functions are nested:
- The intnx("month",input(Invoice_date,YYMMDD10.),-1) part retrieves the first day of the last month
- then the intnx("day",<previous part>, 27) adds 27 days and so retrieves the 28th of the previous month
- the put and the compress function enable to retrieve the date in character in a human readable way (e.g. 20191128). You can remove this step if you want to keep a date.
... View more