/****************************************************************/ /* S A S S A M P L E L I B R A R Y */ /* */ /* NAME: expand1 */ /* TITLE: Example 1 from chapter 11, SAS/ETS User's Guide */ /* PRODUCT: SAS/ETS */ /* SYSTEM: ALL */ /* KEYS: */ /* PROCS: EXPAND */ /* DATA: */ /* */ /* SUPPORT: MRL UPDATE: */ /* REF: SAS/ETS User's Guide, Version 6, First Edition */ /* MISC: Modified Nov.16 1995 by M. Kamstra */ /* */ /****************************************************************/ data quarters; input sales @@; date=intnx('qtr','1oct63'd,_n_); format date yyq.; /* the "intnx" command above creates a SAS date variable, which increments by quarters and starts in the 4th quater of 1963. The date variable is needed for the expand procedure below */ cards; 25.24 24.97 24.37 25.19 24.96 24.38 25.18 24.98 24.50 25.25 25.09 24.61 25.25 25.09 25.61 25.17 26.13 25.60 27.06 25.91 24.57 27.32 28.12 28.45 28.27 29.02 29.79 27.22 28.10 29.49 30.18 25.00 30.60 30.20 30.98 30.46 30.28 30.09 29.73 30.21 30.20 30.63 30.28 30.21 29.60 31.20 31.07 29.59 31.24 31.12 31.64 31.30 31.24 27.75 31.24 31.02 29.74 31.34 31.07 31.58 31.31 31.09 32.51 32.30 32.22 30.66 32.33 32.26 32.81 32.24 32.31 29.63 32.24 32.24 29.77 32.38 32.17 32.82 32.29 32.17 32.78 33.33 33.13 24.68 33.33 33.22 33.74 33.33 33.24 33.89 33.33 35.42 34.99 run; proc expand data=quarters out=annual from=qtr to=year; convert sales / observed=total method=aggregate; id date; run; /* "observed=total" option above is appropriate for flows (i.e. sales, advertising revenues) "observed=average" option would be appropriate for stocks (i.e. unemployment rates, interest rates) */ proc print data=annual; id date; format date year4.; title 'Simple aggregation of quarters to years'; run;