Advanced tables and statistics > Row and table manipulation > Creating averages with row manipulation
 
Creating averages with row manipulation
The averages created by an n07 are the average of values appearing in a row or column; that is, sum of values divided by number of values. To create a row in which the average is the value in one row divided by the value in another row, you must write an m statement with the appropriate expression.
Suppose a tour operator has conducted a survey of the hotels it uses in various places in an effort to improve the service it offers to holiday-makers. As part of this survey, hotel managers are asked how many rooms and beds are available in their hotel each month and, of those, the number actually occupied each month. The tour operator wants a table summarizing hotel usage for a particular month by showing the average number of rooms and beds occupied during that month. Additionally, all averages are to be shown as percentages rather than as absolute values.
This average can be calculated by dividing the number of rooms available by the number occupied and the number of beds available by the number occupied, using row manipulation. If you wanted to break these figures down according to the regions in which the hotels are situated, you would have two axes as follows:
l avers
n10Total Hotels
n01Rooms Available;inc=c(15,18)
n01Rooms Used;inc=c(25,28)
mAverage % Room Occupancy;ex=@1 * 100 / @2
n01Beds Available;inc=c(35,38)
n01Beds Occupied;inc=c(45,48)
mAverage % Bed Occupancy;ex=@1 * 100 / @2
l region
col 10;Base;North;North East;Midlands;East Anglia;
+South West;South East;South;London
If the first hotel has 210 rooms available of which 179 were occupied, the average room occupancy is 85%, ignoring all decimal places.
See also
Row and table manipulation