Revision: 64687
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 7, 2013 02:17 by webonomic
Initial Code
/* Create sample data */ data old; input state $ accttot; datalines; ca 7000 ca 6500 ca 5800 nc 4800 nc 3640 sc 3520 va 4490 va 8700 va 2850 va 1111 ; proc sort data=old; by state; run; /* To get the number of observations in each group of states, start */ /* a counter on the first observation of each BY-Group. The last */ /* observation in the BY-Group contains the total number of */ /* observations and is output to the data set. */ data new; set old (drop= accttot); by state; if first.state then count=0; count+1; if last.state then output; run; proc print; run; /* Alternative approach using PROC FREQ to generate the same output */ proc freq; tables state / out=new(drop=percent); run;
Initial URL
http://support.sas.com/kb/24/595.html
Initial Description
Determine how many observations there are in each BY-Group by using BY-Group processing.
Initial Title
Counting the number of observations in a BY-Group
Initial Tags
Initial Language
SAS