Sample 24688: Create multiple observations from a single observation using multidimensional arrays
Illustrate how to categorize variables based on their
position in a multidimensional array.
Note: In each observation of the data set FRAME, MEN1 and
WOMEN1 belong to the same region. The following DATA
step breaks these observations into multiple
observations, preserving the information of SEX and
REGION.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
data frame;
input men1 men2 men3 men4 men5 woman1 woman2 woman3 woman4 woman5;
datalines;
1 2 3 4 5 6 7 8 9 10
2 3 4 5 6 7 8 9 10 11
3 4 5 6 7 8 9 10 11 12
;
data restructured (drop=men1--j);
set frame;
array SexRegion [2,5] men1--woman5;
do i=1 to 2;
do j=1 to 5;
if i=1 then sex='M';
else sex='F';
region=j;
size=SexRegion[i,j];
output;
end;
end;
run;
proc print;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Obs sex region size
1 M 1 1
2 M 2 2
3 M 3 3
4 M 4 4
5 M 5 5
6 F 1 6
7 F 2 7
8 F 3 8
9 F 4 9
10 F 5 10
11 M 1 2
12 M 2 3
13 M 3 4
14 M 4 5
15 M 5 6
16 F 1 7
17 F 2 8
18 F 3 9
19 F 4 10
20 F 5 11
21 M 1 3
22 M 2 4
23 M 3 5
24 M 4 6
25 M 5 7
26 F 1 8
27 F 2 9
28 F 3 10
29 F 4 11
30 F 5 12
Illustrate how to categorize variables based on their
position in a multidimensional array.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step Data Management ==> Manipulation and Transformation ==> Array processing
|
| Date Modified: | 2006-03-22 03:03:09 |
| Date Created: | 2004-09-30 14:09:04 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |