- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 12-15-2010 05:23 PM
(4981 views)
I have a SAS data set where I have a column of $ values, is there any way
that SAS can add up all the $ values in a column?
I know SAS can add a values in the same row of 2 different columns. But not
sure how I go about adding values in the same column.
Any help is much appreciated.
cheers,
that SAS can add up all the $ values in a column?
I know SAS can add a values in the same row of 2 different columns. But not
sure how I go about adding values in the same column.
Any help is much appreciated.
cheers,
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
SAS has many report procedures that will work for you. PROC PRINT, with the SUM statement, PROC SQL, PROC MEANS, PROC TABULATE, PROC REPORT. The code below shows MEANS, TABULATE and REPORT methods for producing a summary report from a SAS dataset. If you needed to create an output dataset of summary numbers, then all 3 procedures could do that as well.
It sort of boils down to whether you want an output dataset or an output report. The program below creates 1 HTML file with 3 summary reports based on the PRODUCT and SALES variables in SASHELP.SHOES.
cynthia
[pre]
ods html file='c:\temp\sumval.html' style=sasweb;
proc means data=sashelp.shoes sum;
title 'Proc Means';
class product;
var sales;
run;
proc tabulate data=sashelp.shoes f=dollar16.;
title 'Proc TABULATE';
class product;
var sales;
table product all,
n*f=comma6. sum*(sales);
keylabel n='Count'
sum=' ';
run;
proc report data=sashelp.shoes nowd;
title 'Proc REPORT';
column product n sales;
define product / group;
define n / 'Count' f=comma6.;
define sales / sum f=dollar16.;
rbreak after / summarize;
run;
ods _all_ close;
[/pre]
SAS has many report procedures that will work for you. PROC PRINT, with the SUM statement, PROC SQL, PROC MEANS, PROC TABULATE, PROC REPORT. The code below shows MEANS, TABULATE and REPORT methods for producing a summary report from a SAS dataset. If you needed to create an output dataset of summary numbers, then all 3 procedures could do that as well.
It sort of boils down to whether you want an output dataset or an output report. The program below creates 1 HTML file with 3 summary reports based on the PRODUCT and SALES variables in SASHELP.SHOES.
cynthia
[pre]
ods html file='c:\temp\sumval.html' style=sasweb;
proc means data=sashelp.shoes sum;
title 'Proc Means';
class product;
var sales;
run;
proc tabulate data=sashelp.shoes f=dollar16.;
title 'Proc TABULATE';
class product;
var sales;
table product all,
n*f=comma6. sum*(sales);
keylabel n='Count'
sum=' ';
run;
proc report data=sashelp.shoes nowd;
title 'Proc REPORT';
column product n sales;
define product / group;
define n / 'Count' f=comma6.;
define sales / sum f=dollar16.;
rbreak after / summarize;
run;
ods _all_ close;
[/pre]
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
thanks Cynthia, appreciate your help always.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
In SAS,there is SUM statement ( i.e variable+increase ) ,
And sum Function also can do it. Just need to continuely cumulate this variable.
Ksharp
In SAS,there is SUM statement ( i.e variable+increase ) ,
And sum Function also can do it. Just need to continuely cumulate this variable.
Ksharp