by State City;
The figure shows three BY groups. The data set is shown with the BY variables State
and City printed on the left for easy reading. However, the position of the BY variables
in the observations does not matter.
Figure 20.2 BY Groups for the BY Variables State and City
BY group
BY group
St r e e tCi t ySt a t e Z i p Co d e
Do me n i c L n
Gl e e s o n P l
T u c s o n
T u c s o n
8 57 3 0
8 57 3 0
F r e n c h A v e
E g r e t Dr
L a k e l a n d
L a k e l a n d
3 38 0 1
3 38 0 9
Ne r v i a St
Ri c e St
Co r s i c a St
T h o ma s Av e
Su r r e y Dr
T r a d e Av e
Mi a mi
Mi a mi
Mi a mi
Mi a mi
Mi a mi
Mi a mi
3 31 4 6
3 31 3 3
3 31 4 6
3 31 3 3
3 31 3 3
3 31 3 3
BY group
BY variables
AZ
AZ
F L
F L
F L
F L
F L
F L
F L
F L
The observations are arranged so that the observations for Arizona occur first. The
observations within each value of State are arranged in order of the value of City. Each
BY group has a unique combination of values for the variables State and City. For
example, the BY value of the first BY group is AZ Tucson, and the BY value of the
second BY group is FL Lakeland.
Invoking BY-Group Processing
You can invoke BY-group processing in both DATA steps and PROC steps by using a
BY statement. For example, the following DATA step program uses the SET statement
to combine observations from three SAS data sets by interleaving the files. The BY
statement shows how the data is ordered.
data all_sales;
set region1 region2 region3;
by State City Zip;
more SAS statements
run;
This section describes BY-group processing for the DATA step. For information about
BY-group processing with procedures, see “Creating Titles That Contain BY-Group
Information ” in Base SAS Procedures Guide.
452 Chapter 20 BY-Group Processing in the DATA Step
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.108.175