Discover More Tips and Techniques on This Blog

Calculating group totals and the counts within each group

Sample 25217: Calculating group totals and the counts within each group

This example uses the SUM() function to sum the AMOUNT column, creating a new column named GRPTOTAL with a COMMA10. format. The COUNT() function counts the number of occurrences of STATE within each group.

The GROUP BY clause collapses multiple rows for each group into one row per group, containing STATE, GRPTOTAL and the COUNT.


data one; input state $ amount;
cards;
CA 7000
CA 6500
CA 5800
NC 4800
NC 3640
SC 3520
VA 4490
VA 8700
VA 2850
VA 1111 
 
proc sql;
create table two as select state ,sum(amount) as grptotal format=comma10. , count(*) as count from one group by state;
quit


proc print data=two noobs;
run;

 

How to customize page numbers in RTF output

Usage Note 24439: In SAS 9.1, are there easier ways to customize page numbers in RTF output?

direct link here http://support.sas.com/kb/24/439.html

Yes, beginning with SAS 9.1, page numbers can be customized in the RTF destination by using an escape character and the {thispage} function, {lastpage} function, {pageof} function, or all three:

ods escapechar='^';
ods listing close;
ods rtf file='c:\tests\test.rtf';

data test;
do i=1 to 50;
output;
end;
run;



proc print data=test noobs;
title 'Page ^{thispage} of ^{lastpage}';
footnote '^{pageof}';
run;



ods listing;
ods rtf close;





Disclosure:

In the spirit of transparency and innovation, I want to share that some of the content on this blog is generated with the assistance of ChatGPT, an AI language model developed by OpenAI. While I use this tool to help brainstorm ideas and draft content, every post is carefully reviewed, edited, and personalized by me to ensure it aligns with my voice, values, and the needs of my readers. My goal is to provide you with accurate, valuable, and engaging content, and I believe that using AI as a creative aid helps achieve that. If you have any questions or feedback about this approach, feel free to reach out. Your trust and satisfaction are my top priorities.