Below code will create a data structure close to what you asked for. The main difference is that a new month_var will only be created if there is also a corresponding start_date in the data. data have; input City $ Volume Start_Date:ddmmyy. End_Date:ddmmyy.; format Start_Date End_Date ddmmyy10.; Start_Date_BeginMonth=put(intnx('month',Start_Date,0,'b'),date11.); datalines; A 10 2/10/2010 1/11/2010 A 20 2/11/2010 3/12/2010 A 15 5/1/2011 6/2/2011 B 50 7/2/2011 9/3/2011 ; run; proc transpose data=have out=want(drop=_name_); by city volume start_date end_date notsorted; id Start_Date_BeginMonth; var volume; run; proc print data=want; run;
... View more