1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
** Valentim R. Alferes (University of Coimbra, Portugal)
** valferes@fpce.uc.pt

* This syntax job does random assignment of units (subjects) to
* experimental treatments and can be used for Randomized Block
* Designs (Simple or Generalized) and also for Completely Randomized
* Designs with equal n per treatment.

* For Completely Randomized Designs with unequal n per treatment,
* you can use the syntax job posted in:
http://pages.infinit.net/rlevesqu/Syntax/BlockDesign/CRDesigns.txt

* For Randomized Block Designs (Simple), the number of units per block 
* equals the number of treatments (p). The design requires w blocks 
* of p units.

* For the Generalized Randomized Block Designs (see example), the number of
* units per block must be a multiple of the number of treatments (p). The
* design requires w blocks of kp units (k>=2).

* For Completely Randomized Designs with equal n per treatment, you
* must enter number of blocks = 1.

* In the example (Generalized Randomized Block Design) we have:
* 18 subjects (units);
* 3 treatments (p);
* 2 blocks (w);
* 9 subjects per block (9=3p).



DATA LIST FREE /TREAT(A20).
* Enter treatments names (A, B and C in the example).
BEGIN DATA
A B C 
END DATA.
COMPUTE TREATM=$CASENUM.
SAVE OUTFILE=OUTF1.

INPUT PROGRAM.
* Enter number of cases (18 in the example).
LOOP N_CASES=1 TO 18.
* Enter number of treatments (3 in the example).
COMPUTE N_TREATM=3.
* Enter number of blocks (2 in the example).
COMPUTE N_BLOCKS=2.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.

COMPUTE TREATM=MOD($CASENUM,N_TREATM)+1.
SORT CASES BY TREATM (A).
MATCH FILES/FILE=*/TABLE=OUTF1/BY TREATM.
COMPUTE BLOCK=MOD($CASENUM,N_BLOCKS)+1.
SORT CASES BY BLOCK(A) TREAT(A).
SET SEED RANDOM.
COMPUTE RANDOM=RV.UNIFORM(0,1).
SORT CASES BY BLOCK(A) RANDOM(A).
RANK VARIABLES=RANDOM(A) BY BLOCK.
COMPUTE ID=RRANDOM.
FORMATS ID(F8.0) BLOCK(F8.0).
LIST ID BLOCK TREAT.
SORT CASES BY TREAT (A) BLOCK (A) ID (A) .
SPLIT FILE SEPARATE BY TREAT .
LIST BLOCK ID.



* Note 1:
* You can enter any treatment names (up to 20 characters). For example,
* in a Randomized Block Design (Simple) with 10 blocks and 3 treatments:
*    […]
*    BEGIN DATA
*    Treatment_1 Treatment_2 Treatment_3
*    END DATA.
*    […]
*    LOOP N_CASES=1 TO 30.
*    […]
*    COMPUTE N_TREATM=3.
*    […]
*    COMPUTE N_BLOCKS=10.
*    […]



* Note 2:
* Remember to enter N_BLOCKS = 1 in Completely Randomized Designs.
* For example, in a Completely Randomized Factorial Design with 6 treatments, 
* 48 subjects and equal number of subjects per treatment, you have to enter: 
*    […]
*    BEGIN DATA
*    A1B1 A1B2 A2B1 A2B2 A3B1 A3B2
*    END DATA.
*    […]
*    LOOP N_CASES=1 TO 48.
*    […]
*    COMPUTE N_TREATM=6.
*    […]
*    COMPUTE N_BLOCKS=1.
*    […].