# The SURVEYMEANS Procedure

### Example 92.5 Variance Estimation Using Replication Methods

In order to improve service, the San Francisco Municipal Railway (MUNI) conducts a survey to estimated passenger’s average waiting time for MUNI’s subway system.

The study uses a stratified cluster sample design. Each MUNI subway line is a stratum. The subway lines included in the study are 'J-Church,' 'K-Ingleside,' 'L-Taraval,' 'M-Ocean View,' 'N-Judah,' and the street car 'F-Market & Wharves.' The MUNI vehicles in service for these lines during a day are primary sampling units. Within each stratum, two vehicles (PSUs) are randomly selected. Then the waiting times of passengers for a selected MUNI vehicle are collected.

Table 92.6 shows the number of passengers that are interviewed in each of the selected MUNI vehicles.

Table 92.6: The Sample of the MUNI Waiting Time Study

MUNI Line

Vehicle

Number of Passengers

F-Market & Wharves

1

65

2

102

J-Church

1

101

2

142

K-Ingleside

1

145

2

180

L-Taraval

1

135

2

185

M-Ocean View

1

139

2

203

N-Judah

1

306

2

234

The collected data are saved in the SAS data set `MUNIsurvey`. The variable `Line` indicates which MUNI line a passenger is riding. The variable `vehicle` identifies the vehicle that a passenger is boarding. The variable `Waittime` is the time (in minutes) that a passenger waited. The variable `weight` contains the sampling weights, which are determined by selection probabilities within each stratum.

Output 92.5.1 displays the first 10 observations of the data set `MUNIsurvey`.

Output 92.5.1: First 10 Observations in the Data Set from the MUNI Subway Survey

 MUNI Subway Passenger Waiting Time Survey Data

Obs line vehicle passenger waittime weight
1 F-Market & Wharves 1 1 18 59
2 F-Market & Wharves 1 2 0 59
3 F-Market & Wharves 1 3 16 59
4 F-Market & Wharves 1 4 13 59
5 F-Market & Wharves 1 5 5 59
6 F-Market & Wharves 1 6 13 59
7 F-Market & Wharves 1 7 7 59
8 F-Market & Wharves 1 8 5 59
9 F-Market & Wharves 1 9 16 59
10 F-Market & Wharves 1 10 5 59

Using the VARMETHOD=BRR option, the following SAS statements analyze the MUNI subway survey by using the BRR method to estimate the variance:

```title 'MUNI Passenger Waiting Time Analysis Using BRR';
proc surveymeans data=MUNIsurvey mean varmethod=brr mean clm;
strata line;
cluster vehicle;
var waittime;
weight weight;
run;
```

The STRATUM variable is `line`, which corresponds to MUNI lines. The two clusters within each stratum are identified by the variable `vehicle`. The sampling weights are stored in the variable `weight`. The mean and confident limits for passenger waiting time (in minutes) are requested statistics.

Output 92.5.2 summarizes the data and indicates that the variance estimation method is BRR with 8 replicates.

Output 92.5.2: MUNI Passenger Waiting Time Analysis Using the BRR Method

 MUNI Passenger Waiting Time Analysis Using BRR

The SURVEYMEANS Procedure

Data Summary
Number of Strata 6
Number of Clusters 12
Number of Observations 1937
Sum of Weights 143040

Variance Estimation
Method BRR
Number of Replicates 8

Output 92.5.3 reports that the average passenger waiting time for a MUNI vehicle is 7.33 minutes, with an estimated standard of 0.24 minutes, using the BRR method. The 95% confident limits for the mean are estimated as 6.75 to 7.91 minutes.

Output 92.5.3: MUNI Passenger Waiting Time Analysis Using the BRR Method

Statistics
Variable Mean Std Error of Mean 95% CL for Mean
waittime 7.333012 0.237557 6.75172983 7.91429366

Alternatively, the variance can be estimated using the jackknife method if the VARMETHOD=JACKKNIFE option is used. The following SAS statements analyze the MUNI subway survey by using the jackknife method to estimate the variance:

```title 'MUNI Passenger Waiting Time Analysis Using Jackknife';
proc surveymeans data=MUNIsurvey mean varmethod=jackknife mean clm;
strata line;
cluster vehicle;
var waittime;
weight weight;
run;
```

Output 92.5.4 summarizes the data and indicates that the variance estimation method is jackknife with 12 replicates.

Output 92.5.4: MUNI Passenger Waiting Time Analysis Using the Jackknife Method

 MUNI Passenger Waiting Time Analysis Using Jackknife

The SURVEYMEANS Procedure

Data Summary
Number of Strata 6
Number of Clusters 12
Number of Observations 1937
Sum of Weights 143040

Variance Estimation
Method Jackknife
Number of Replicates 12

Output 92.5.5 reports the statistics computed using the jackknife method. Although the average passenger waiting time remains the same (7.33 minutes), the standard error is slightly smaller 0.23 minutes when the jackknife method is used, as opposed to 0.24 minutes when the BRR method is used. The 95% confidence limits are between 6.76 and 7.90 minutes when the jackknife method is used.

Output 92.5.5: MUNI Passenger Waiting Time Analysis Using the Jackknife Method

Statistics
Variable Mean Std Error of Mean 95% CL for Mean
waittime 7.333012 0.232211 6.76481105 7.90121244