libname y 'y:\SAS\arrays'; data mountaineers(drop=check y m); set y.mountaineers; array months{2000:2007,12} /* an array of two dimensions */ m200001-m200012 m200101-m200112 m200201-m200212 m200301-m200312 m200401-m200412 m200501-m200512 m200601-m200612 m200701-m200712; * In the PDV, this is just one long list of variables, so in the data set this is still one observation. However, our processing logic will treat it as a two dimensional array. One observation, whose data values are processed in two dimensions.; check="01Feb2000"d; do y = 2000 to 2007; /* with any array, we can index over an arbitrary sequence of numbers, spaced at regular intervals */ do m = 1 to 12; months{y,m}= date lt check and expdate ge check; check = intnx("month", check, 1); end; end; run; * Everything after this point is manipulation to make a graph, and nothing to do with arrays.; proc means data=mountaineers sum; var m200006--m200706; output out=monthly sum=; run; proc transpose data=monthly(drop=_type_ _freq_) out=monthcounts(rename=(_name_=yearmonth col1=count)); run; data monthcounts; set monthcounts; date = mdy(substr(yearmonth,6,2),1,substr(yearmonth,2,4)); format date monyy7.; run; proc sgplot data=monthcounts; series y=count x=date; run;