Programming the statistical procedures from SAS

proc surveyselect and sampling 2 consecutive days from each week.

Reply
New Contributor
Posts: 3

proc surveyselect and sampling 2 consecutive days from each week.

I am trying to randomly select a survey schedule that includes both weekend days and two consecutive weekdays over a 34 week period.  I have created a data set that has all combinations of the variables (example below) with a total of 532 possibilities:

 

 Obs    RESERVOIR    week    day     section        start

                                   1        1          1     MON        1       Start Site - 1
                                   2        1          1     MON        2       Start Site - 1
                                   3        1          1     MON        1       Start Site - 2
                                   4        1          1     MON        2       Start Site - 2
                                   5        1          1     TUES       1       Start Site - 1
                                   6        1          1     TUES       2       Start Site - 1
                                   7        1          1     TUES       1       Start Site - 2
                                   8        1          1     TUES       2       Start Site - 2
                                   9        1          1     WED        1       Start Site - 1
                                  10        1          1     WED        2       Start Site - 1
                                  11        1          1     WED        1       Start Site - 2
                                  12        1          1     WED        2       Start Site - 2
                                  13        1          1     THUR       1       Start Site - 1
                                  14        1          1     THUR       2       Start Site - 1
                                  15        1          1     THUR       1       Start Site - 2
                                  16        1          1     THUR       2       Start Site - 2
                                  17        1          2     MON        1       Start Site - 1
                                  18        1          2     MON        2       Start Site - 1
                                  19        1          2     MON        1       Start Site - 2
                                  20        1          2     MON        2       Start Site - 2
                                  21        1          2     TUES       1       Start Site - 1
                                  22        1          2     TUES       2       Start Site - 1
                                  23        1          2     TUES       1       Start Site - 2
                                  24        1          2     TUES       2       Start Site - 2
                                  25        1          2     WED        1       Start Site - 1
                                  26        1          2     WED        2       Start Site - 1
                                  27        1          2     WED        1       Start Site - 2
                                  28        1          2     WED        2       Start Site - 2
                                  29        1          2     THUR       1       Start Site - 1
                                  30        1          2     THUR       2       Start Site - 1
                                  31        1          2     THUR       1       Start Site - 2
                                  32        1          2     THUR       2       Start Site - 2

 

For this section i am only dealing with the weekdays portion, but so far i have the following SAS program:

 

PROC SURVEYSELECT DATA=weekdays METHOD=SRS n=2 OUT=weekdaysa noprint;
    STRATA week day;
RUN;

 

This does select 2 days per week but sometimes selects the same day for the week.  I would like the days to be consecutive (e.g., if monday is selected, then Tuesday would also be selected).

 

Thanks for any assistance.

 

 

Grand Advisor
Posts: 10,062

Re: proc surveyselect and sampling 2 consecutive days from each week.

Since your second day is not randomly selected you might think of selecting the first "day" (I'm sort of confused with a numeric variable day that correspondes to 4 day names per week) and then use that information to indicate the following day is to be used in a data step.

 

Are you picking all of the start and startsites for a given day of the week?

 

It may help to show what an example desired result sample might look like from your shown example input data.

New Contributor
Posts: 3

Re: proc surveyselect and sampling 2 consecutive days from each week.

yes, i select the start (which is an am/pm variable) and the start site for each date. The results that i get now are often like this:

 

 Obs    week    RESERVOIR    day     section    start       Prob       Weight

                           1      1         1        WED        1         2        0.125          8
                           2      1         1        THUR       1         1        0.125          8
                           3      2         1        TUES       2         2        0.125          8
                           4      2         1        WED        2         1        0.125          8
                           5      3         1        MON        1         1        0.125          8
                           6      3         1        WED        2         2        0.125          8
                           7      4         1        MON        1         1        0.125          8
                           8      4         1        WED        2         2        0.125          8
                           9      5         1        MON        1         2        0.125          8
                          10      5         1        THUR       2         2        0.125          8
                          11      6         1        WED        2         1        0.125          8
                          12      6         1        THUR       2         1        0.125          8
                          13      7         1        MON        1         1        0.125          8
                          14      7         1        TUES       1         2        0.125          8
                          15      8         1        TUES       2         2        0.125          8
                          16      8         1        WED        2         1        0.125          8
                          17      9         1        THUR       1         2        0.125          8
                          18      9         1        THUR       2         2        0.125          8

Where in week 9, i get Thursday picked twice. 

Grand Advisor
Posts: 10,062

Re: proc surveyselect and sampling 2 consecutive days from each week.

Okay, you've shown what you currently get. What do you want the output to look like?

 

Also since you are thinking "consecutive" then you really need to address "DAY" as character. THUR is the day after MON in your values.

 

Suppose I select the record with:

 2        1          1     MON        2       Start Site - 1

Then I believe you are requesting another record in week 1 that is day=TUES. The second day is determined by the first selected so is not random.

Is there any rule involved for what to pick from the following day? Same section and start? Same section different start? Different Section same start? Different section and different start? Random section and start?

 

And what if Thur is the first picked? There isn't any "consecutive" day as in following within the same week. Or would that mean that if

THUR is selected you need a WED?

 

 

 

 

 

 

New Contributor
Posts: 3

Re: proc surveyselect and sampling 2 consecutive days from each week.

Ballardw, thanks for the help. I decided to brute force it with data steps and have solved my problem.

Thanks again.
Ask a Question
Discussion stats
  • 4 replies
  • 71 views
  • 0 likes
  • 2 in conversation