DM Stat-1 Articles
Link to Home

Link to Articles

Link to Consulting

Link to Seminar

Link to Stat-Chat

Link to Software

Link to Clients

Technical Report #12:
Counting the Number of Records in a By-Group

Bruce Ratner, Ph.D.

It is always important to have a count vis-a-vis EDA of the number of records for each value or level of a categorial variable under consideration. The SAS-code program, below, provides a quick way to count the number of such records.


********** SAS-code Program **********

DATA
 IN;
input ID 2. GENDER $1. MARITAL $1.;
cards;
01MS
02MM
03M
04
05FS
08FM
07F
08 M
09 S
10MD

RUN;
PROC SORT;
by gender;
RUN;
DATA 
GENDER_COUNT;
set IN;
by GENDER;
if first.GENDER then GENDER_COUNT=0;
GENDER_COUNT+1;
if last.GENDER then output GENDER_COUNT; 
RUN; 
PROC PRINT data=GENDER_COUNT (keep=GENDER GENDER_COUNT);
RUN;



For more information about this article, call Bruce Ratner at 516.791.3544,
1 800 DM STAT-1, or e-mail at br@dmstat1.com.