@Kyojik Hi, Sorry for not being able to give you the much needed solution last night as I was awefully tired. Here you go, the below will work for multiple companies. Please do let me know should if it doesn't quite meet your requirement. It's actually easy. So feel free to reach out. Regards, Naveen Srinivasan proc sort data=have; by companyname year month; run; data want(rename=(_month=month)); do until(last.companyname); do until(last.year); set have; by companyname year month; length _type __type $1; if first.companyname or first.year then call missing(_month,_type,__type); if first.year and last.year and month=12 then do; _month=month; output; end; else if (first.year and last.year) and month<12 then do; do _month=month to 12; output; end; end; else if (first.year and not last.year) and month<12 then do; _month=month; _type=type; end; else if not first.year then do; __type=type; do _month=_month to month-1; type=_type; output; end; _type=__type; if last.year then do; do _month=month to 12; type=_type; output; end; end; end; end; end; drop month _type __type; run;
... View more