—•Today is •—

In this example, the use of SUM() function is to sum the PAID column; it is also creating a new column named PAIDTOTAL.  And the COUNT() function tallies the total number of occurrences of LOB (line of business) within each group.

Using the GROUP BY clause, it aggregates multiple rows for each group of line of business into one row per group.


	proc sql;
	  create table workdata as 
	  select state, 
	         sum(paid) as PAIDTOTAL format=dollar12., 
	         count(*) as COUNT format=comma10.
	  from test
	  group by state
	  ;
	quit;

	proc print data=workdata;
	run;

	SAS Output

	Obs     LOB     TOTAL_PAID     COUNT

	 1                      $0       676
	 2       HM    $91,094,122    19,284
	 3       MD    $27,323,992     7,531
	 4       MR   $150,157,470    22,294
	 5       MS       $654,659     1,426
	 6       PS     $4,572,845       787
				

Print Document

Copyright © 2006 www.nycinformatics®.com All Rights Reserved
Last edited on: June 14, 2006
SAS product or service names are registered trademarks of SAS Institute, Inc. in the USA and other countries.
® indicates USA registration.