10.7 - Using Across Variables10.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.
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;
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|
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?