# 10.7 - Using Across Variables

10.7 - Using Across Variables

Thus far, we've investigated display, analysis, order, and group variables. You can also define variables as across variables, which are functionally similar to group variables. However, when you define a variable as being an across variable, SAS displays the groups that it creates horizontally rather than vertically.

## Example 10.17

The following program is nearly identical to the program in Example 10.14 which concerned the illustration of the use of a group variable. The only difference between the two programs is that the group keyword in the DEFINE statement for the Type variable has been replaced here with the across keyword:

PROC REPORT data = stat480.penngolf NOWINDOWS HEADLINE;
title 'Some Pennsylvania Golf Courses';
column Type Par Yards;
define Type / across 'Type of/Course' spacing = 6
width = 8 center;
define Par / analysis 'Total/Par';
define Yards / analysis format = comma6.0 'Total/Yardage'
width = 7 spacing = 4 center;
RUN;
##### Some Pennsylvania Golf Courses
Private Public Resort SemiPri Total Par Total Yardage
3 1 2 5 783 72,300

You might want to recall that when the group keyword was used in the DEFINE statement for the Type variable, the resulting report looked like this:

##### Some Pennsylvania Golf Courses
Type of Course Total Par Total Yardage
Private 214 19,660
Public 72 6,525
Resort 144 14,141
SemiPri 353 31,974

Now, launch and run the SAS program, and review the output to see the effect of replacing the group keyword with the across keyword. You should first note that, as claimed, the values of the Type variable are displayed horizontally rather than vertically. Then, you should observe that for the across variable, the table cells contain a frequency count for each Type of golf course. That is, the report indicates that the data set contains three private courses, one public course, two resort courses, and five semi-private courses. For the two analysis variables, Par and Yards, SAS displays the sum of all of their values. Quite a different report, eh?

 [1] Link ↥ Has Tooltip/Popover Toggleable Visibility