adding a new column (sum) using PROC MEANS

Reply
Occasional Contributor
Posts: 8

adding a new column (sum) using PROC MEANS

Hi All,

Can any body tell how can I add an extra column "sum" in the below output ?

Summary of Flower Sales by Month                 1

--------------------------------- Month=5 ---------------------------------

                        The MEANS Procedure
Variable N       Mean    Std Dev    Minimum    Maximum

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

Petunia  3 86.6666667 35.1188458 50.0000000120.0000000
SnapDragon   3113.3333333 41.6333200 80.0000000160.0000000
Marigold 3 81.6666667 25.6580072 60.0000000110.0000000

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

--------------------------------- Month=6 ---------------------------------

Variable N       Mean    Std Dev    Minimum    Maximum

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

Petunia  4 81.2500000 16.5201897 60.0000000100.0000000
SnapDragon   4 97.5000000 47.8713554 60.0000000160.0000000
Marigold 4 83.7500000 19.7378655 60.0000000100.0000000

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

I am using the following code snippet to print the above output. I have attached the input file Flowers.txt herewith.

<code>

DATA sales;

   INFILE 'c:\MyRawData\Flowers.txt';

   INPUT CustomerID $ @9 SaleDate MMDDYY10. Petunia SnapDragon

         Marigold;

   Month = MONTH(SaleDate);

PROC SORT DATA = sales;

   BY Month;

* Calculate means by Month for flower sales;

PROC MEANS DATA = sales;

   BY Month;

   VAR Petunia SnapDragon Marigold;

   TITLE 'Summary of Flower Sales by Month';

RUN;

</code>

Thanks.....................

Attachment
Super Contributor
Posts: 1,636

Re: adding a new column (sum) using PROC MEANS

Is this helpful?

proc sort data=sashelp.class out=class;

by sex;

proc means data=class N  Mean  Std  Min  Max  sum;

by sex;

var age;

run;

Sex=F

The MEANS Procedure

                             Analysis Variable : Age

N            Mean         Std Dev         Minimum         Maximum             Sum

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

9      13.2222222       1.3944334      11.0000000      15.0000000     119.0000000

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

Sex=M

                             Analysis Variable : Age

N            Mean         Std Dev         Minimum         Maximum             Sum

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

10      13.4000000       1.6465452      11.0000000      16.0000000     134.0000000

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

Linlin

Occasional Contributor
Posts: 8

Re: adding a new column (sum) using PROC MEANS

thanks it worked for me.

Ask a Question
Discussion stats
  • 2 replies
  • 555 views
  • 3 likes
  • 2 in conversation