The SAS Output Delivery System and reporting techniques

Displaying the number of by group values at the bottom of the report

Reply
N/A
Posts: 0

Displaying the number of by group values at the bottom of the report

Hi,
My code is as follows
proc sort data=sashelp.class out=class;
by sex;
run;
ods pdf;
proc report data=class nowd;
by sex;
run;
ods pdf close;

On Excueting the above code,I am getting the table with SEX='F' in first page and SEX='M' in second page.Now I want to display the number of Females at the bottom of first page as ' Total number of Females: 9 ' and the number of Males at the bottom of second page as ' Total number of Males: 10 '.
Please help me in doing the above task.

Thanks in advance.
N/A
Posts: 0

Re: Displaying the number of by group values at the bottom of the report

not only can you (clip from TITLE online doc)
Example 2: Customizing Titles by Using BY Variable Values
as in the link http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a000220968.htm#a002659438 , iirc, you can place the same customisation into footnotes.

PeterC
N/A
Posts: 0

Re: Displaying the number of by group values at the bottom of the report

Hi Peter,
I don't want to insert either the Value of By-Variable or the Name of By-Variable or the By-Line ,I want to insert the number of obervations present in each By group at the bottom of the respective tables .
N/A
Posts: 0

Re: Displaying the number of by group values at the bottom of the report

sorry Sivas

Even having obtained a solution that populates the by-value with the count for the by-group, it will still not be enough anyway, because you want it in the footer.
I'm now safely able to declare (from testing in SAS913) that #byval and #byvar do not operate in footnotes.

I expect Cynthia has found a solution for you.


PeterC
SAS Super FREQ
Posts: 8,739

Re: Displaying the number of by group values at the bottom of the report

Hi:
I had a version of this program as an example in my paper, Creating Complex Reports, which I presented at SAS Global Forum. The paper can be found here:
http://www2.sas.com/proceedings/forum2008/173-2008.pdf (see page 2 for your report...it can be produced with PROC PRINT, PROC REPORT and DATA _NULL_).

And the programs can be downloaded from here:
http://support.sas.com/rnd/papers/ (scroll until you see the paper title....then follow the link to download the zip file of programs.)

There are a couple of other ways to put extra summary lines at the bottom of PROC REPORT output, without going down the PROC TEMPLATE road (just yet!).

cynthia
ps...in the programs to download, this program is called figure1_2.sas -- however, it did not use BY group processing. I've changed the PROC REPORT example below to use BY group processing (in which case, you might want to NOPRINT the DEFINE statement for SEX in the code, after you see how it's working.)
[pre]
proc sort data=sashelp.class out=class;
by sex name;
run;

title; footnote;
ods listing close;
ods html file='figure1_2.html' style=egdefault;

proc report data=class nowd
style(summary) = Header
style(lines) = Header;
by sex;
column sex name age height height=htdisp;
define sex / group
style(column)=Header;
define name / display;
define age / display;
define height / n noprint;
define htdisp /sum;

compute after sex;
if sex = 'F' then
prtline = 'Female Students N ='||put(height.n,3.0);
else if sex = 'M' then
prtline = 'Male Students N ='||put(height.n,3.0);
line prtline $30.;
endcomp;

run;
ods html close;
[/pre]
Ask a Question
Discussion stats
  • 4 replies
  • 139 views
  • 0 likes
  • 2 in conversation