Don't Be a SAS® Dinosaur: Modernize Your SAS Programs
by Warren Repole

Details for the Summary data sources


Download the program that creates the Summary data sources [The complete program is shown below.]

 
________________________________________________________________________________________________________________________
 
SUMMER_PRDTOT2 data set

Date           Actual         Predict    COUNTRY       PRODTYPE

JUN96         $471.57         $367.63    U.S.A.        OFFICE    
JUL96         $530.22         $309.91    U.S.A.        OFFICE    
AUG96         $309.23         $506.34    U.S.A.        OFFICE    
JUN97         $656.92         $476.08    U.S.A.        OFFICE    
JUL97         $534.46         $496.69    U.S.A.        OFFICE    
AUG97         $415.38         $479.08    U.S.A.        OFFICE    
 
________________________________________________________________________________________________________________________
 
SUMMER_PRDTOT3 data set

DATE           Actual         Predict    COUNTRY       PRODTYPE

JUN97       $8,540.00       $6,189.00    U.S.A.        OFFICE    
JUL97       $6,948.00       $6,457.00    U.S.A.        OFFICE    
AUG97       $5,400.00       $6,228.00    U.S.A.        OFFICE    
JUN98       $8,429.30       $6,571.40    U.S.A.        OFFICE    
JUL98       $9,477.60       $5,539.60    U.S.A.        OFFICE    
AUG98       $5,527.50       $9,050.80    U.S.A.        OFFICE    
 
________________________________________________________________________________________________________________________
 
PRDSUMMARY data set

PRODUCT          DATE          Actual

CHAIR         1997M01      $90,968.00
CHAIR         1997M02     $101,511.00
CHAIR         1997M03     $102,715.00
CHAIR         1997M04      $95,294.00
CHAIR         1997M05      $99,894.00
CHAIR         1997M06      $97,703.00
CHAIR         1997M07      $98,147.00
CHAIR         1997M08     $100,561.00
CHAIR         1997M09      $93,650.00
CHAIR         1997M10     $104,921.00
CHAIR         1997M11     $105,908.00
CHAIR         1997M12     $104,074.00
CHAIR         1998M01     $111,621.40
CHAIR         1998M02     $115,781.60
CHAIR         1998M03     $110,319.00
CHAIR         1998M04     $127,020.30
CHAIR         1998M05     $105,700.10
CHAIR         1998M06     $124,609.10
CHAIR         1998M07     $126,055.60
CHAIR         1998M08     $118,225.80
CHAIR         1998M09     $110,495.00
CHAIR         1998M10     $118,376.50
CHAIR         1998M11     $119,070.60
CHAIR         1998M12     $114,023.80
DESK          1997M01     $102,956.00
DESK          1997M02     $101,370.00
DESK          1997M03      $94,325.00
DESK          1997M04     $110,380.00
DESK          1997M05     $105,001.00
DESK          1997M06     $108,058.00
DESK          1997M07     $108,354.00
DESK          1997M08      $98,607.00
DESK          1997M09     $104,398.00
DESK          1997M10     $101,814.00
DESK          1997M11     $108,792.00
DESK          1997M12      $98,927.00
DESK          1998M01     $105,909.10
DESK          1998M02     $117,751.70
DESK          1998M03     $123,704.90
DESK          1998M04     $115,020.40
DESK          1998M05     $111,285.90
DESK          1998M06     $110,156.20
DESK          1998M07     $107,627.30
DESK          1998M08     $119,838.40
DESK          1998M09     $112,270.40
DESK          1998M10     $110,569.80
DESK          1998M11     $113,918.20
DESK          1998M12     $114,243.80
 
________________________________________________________________________________________________________________________
 
ALLYEARS Data Set

Obs    STATE                        Sales1995       Sales1996       Sales1997       Sales1998

 1     British Columbia            $42,788.80      $46,502.40      $53,486.00      $58,128.00
 2     Ontario                     $34,665.60      $45,286.40      $43,332.00      $56,608.00
 3     Quebec                      $44,324.00      $44,454.40      $55,405.00      $55,568.00
 4     Saskatchewan                $40,048.00      $49,543.20      $50,060.00      $61,929.00
 
________________________________________________________________________________________________________________________
 
SALES1997 Data Set

Obs      Date          Actual         Predict

 1     1996Q1         $695.26       $1,094.46
 2     1996Q2       $1,257.42         $954.65
 3     1996Q3       $1,408.18       $1,145.54
 4     1996Q4       $1,138.58       $1,063.32
 5     1997Q1       $1,382.69       $1,524.15
 6     1997Q2       $1,944.15       $1,095.23
 7     1997Q3       $1,533.15       $1,317.15
 8     1997Q4       $1,370.77       $1,881.31
 
________________________________________________________________________________________________________________________
 
TRANSACTIONS Data Set

Obs      DATE          Actual

 1     1997Q1      $17,975.00
 2     1997Q2      $25,274.00
 3     1997Q3      $19,931.00
 4     1997Q4      $17,820.00
 
________________________________________________________________________________________________________________________
 
STARTOFMONTH Data Set

Obs    DATE           Actual

  1    JAN97       $4,943.00
  2    FEB97       $7,595.00
  3    MAR97       $5,437.00
  4    APR97       $8,467.00
  5    MAY97       $8,267.00
  6    JUN97       $8,540.00
  7    JUL97       $6,948.00
  8    AUG97       $5,400.00
  9    SEP97       $7,583.00
 10    OCT97       $4,842.00
 11    NOV97       $7,508.00
 12    DEC97       $5,470.00
 
________________________________________________________________________________________________________________________
 
ENDOFMONTH Data Set

Obs         DATE          Actual

  1    31JAN2008       $4,943.00
  2    28FEB2008       $7,595.00
  3    31MAR2008       $5,437.00
  4    30APR2008       $8,467.00
  5    31MAY2008       $8,267.00
  6    30JUN2008       $8,540.00
  7    31JUL2008       $6,948.00
  8    31AUG2008       $5,400.00
  9    30SEP2008       $7,583.00
 10    31OCT2008       $4,842.00
 11    30NOV2008       $7,508.00
 12    31DEC2008       $5,470.00
 
________________________________________________________________________________________________________________________
 
PRDTOT2 data set

Obs    MONYR          Total2

  1    JAN97     $330,354.95
  2    FEB97     $337,752.15
  3    MAR97     $332,699.62
  4    APR97     $332,928.25
  5    MAY97     $350,666.56
  6    JUN97     $333,118.68
  7    JUL97     $340,737.35
  8    AUG97     $341,851.84
  9    SEP97     $357,404.88
 10    OCT97     $358,452.41
 
________________________________________________________________________________________________________________________
 
PRDTOT3 data set

Obs    DATE           Total3

  1    JAN97     $407,515.00
  2    FEB97     $419,927.00
  3    MAR97     $396,236.00
  4    APR97     $413,626.00
  5    MAY97     $417,042.00
  6    JUN97     $409,394.00
  7    JUL97     $423,352.00
  8    AUG97     $412,309.00
  9    SEP97     $421,428.00
 10    OCT97     $427,881.00

Program Code

  /* Create data sets for comparisons */
proc means data=sashelp.prdsal2(rename=(MonYr=Date)) noprint nway;
  where state="Illinois" and County="Cook" and Product="CHAIR"
    and Date between "01jan1996"d and "31dec1997"d
    and month(Date) between 6 and 8;
  class Date;
  id Country ProdType;
  var Actual Predict;
  output out=Summer_prdtot2 sum=Actual Predict;
run;
proc print data=Summer_prdtot2;
  id Date;
  var Actual Predict Country ProdType;
  title1 "SUMMER_PRDTOT2 data set";
run;
proc means data=sashelp.prdsal3 noprint nway;
  where state="Illinois" and County="Cook" and Product="CHAIR"
    and month(Date) between 6 and 8;
  class Date;
  id Country ProdType;
  var Actual Predict;
  output out=Summer_prdtot3 sum=Actual Predict;
run;
proc print data=Summer_prdtot3;
  id Date;
  var Actual Predict Country ProdType;
  title1 "SUMMER_PRDTOT3 data set";
run;

  /* Create data set for transposing */
proc means data=sashelp.prdsal3 noprint nway;
  where ProdType='OFFICE';
  class Product Date;
  format Date yymm7.;
  var Actual;
  output out=PrdSummary(drop=_type_ _freq_) sum=Actual;
run;
proc print data=PrdSummary;
  id Product Date;
  title1 "PRDSUMMARY data set";
run;

proc means data=sashelp.prdsal2 noprint nway;
  where Country="Canada" and Product="CHAIR";
  class State MonYr;
  var Actual;
  format MonYr year4.;
  output out=Annual sum=Actual;
run;
proc transpose data=Annual out=AllYears(drop=_Name_ _label_) prefix=Sales;
  by State;
  id MonYr;
  var Actual;
run;
proc print data=AllYears;
  title1 "ALLYEARS Data Set";
run;

  /* Create data sets for updates */
proc means data=sashelp.prdsal2(rename=(MonYr=Date)) noprint nway;
  where state="Illinois" and County="Cook" and Product="CHAIR"
    and Date between "01jan1996"d and "31dec1997"d;
  class Date;
  format Date yyq6.;
  var Actual Predict;
  output out=Sales1997(index=(Date) drop=_TYPE_ _FREQ_) sum=Actual Predict;
run;
proc print data=Sales1997;
  title1 "SALES1997 Data Set";
run;
proc means data=sashelp.prdsal3 noprint nway;
  where state="Illinois" and County="Cook" and Product="CHAIR"
    and Date between "01jan1997"d and "31dec1997"d;
  class Date;
  format Date yyq6.;
  var Actual;
  output out=transactions(drop=_TYPE_ _FREQ_) sum=Actual;
run;
proc print data=transactions;
  title1 "TRANSACTIONS Data Set";
run;

  /* End of Month Sales Data */
proc means data=sashelp.prdsal3 noprint nway;
  where state="Illinois" and County="Cook" and Product="CHAIR"
    and Date between "01jan1997"d and "31dec1997"d;
  class Date;
  var Actual;
  output out=StartOfMonth(drop=_TYPE_ _FREQ_) sum=Actual;
run;
proc print data=StartOfMonth;
  title1 "STARTOFMONTH Data Set";
run;
data EndOfMonth;
  set StartOfMonth;
  Date=intnx("month",Date,0,"E");
  Date=intnx("year",Date,11,"SAME");
  format Date date9.;
run;
proc print data=EndOfMonth;
  title1 "ENDOFMONTH Data Set";
run;

  /* Create summary data for merging */
proc means data=sashelp.prdsal2 noprint nway;
  where year=1997;
  class MonYr;
  var Actual;
  output out=prdtot2(drop=_FREQ_ _TYPE_) sum=Total2;
run;
proc print data=prdtot2(obs=10);
  var MonYr Total2;
  title1 "PRDTOT2 data set";
run;
proc means data=sashelp.prdsal3 noprint nway;
  where year=1997;
  class Date;
  var Actual;
  output out=prdtot3(drop=_FREQ_ _TYPE_) sum=Total3;
run;
proc print data=prdtot3(obs=10);
  var Date Total3;
  title1 "PRDTOT3 data set";
run;


SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries.
® indicates USA registration.