![]() |
SHUFFLE GROUPSName:
The size of the index variable should be equal to the number of groups in the group-id variable. Although this command was motivated by cases where the group sizes are equal, this is not required. If the group sizes are note equal, the output variable may not be the same length as the input variable.
<SUBSET/EXCEPT/FOR qualification> where <y> is a response variable; <x> is a group-id variable; <index> is a variable defining the order for the groups in the output variable; <y2> is a response variable containing the re-arranged groups; and where the <SUBSET/EXCEPT/FOR qualification> is optional. The response variable and group-id variable should have the same number of elements. The index variable must be the same size as the number of groups in the group-id variable. If there are k groups in the group-id variable, then the values in the index variable should be between 1 and k. An error will be reported if they are not.
. Step 1: Read the data . read x y 1 1 1 2 1 3 1 4 1 5 2 11 2 12 2 13 2 14 2 15 3 21 3 22 3 23 3 24 3 25 4 31 4 32 4 33 4 34 4 35 end of data . . Step 2: Now reshuffle the groups . let iindex = data 3 1 4 2 let yout = shuffle groups y x iindex . . Step 3: Print the results . set write decimals 0 print x y youtThe following output is generated --------------------------------------------- X Y YOUT --------------------------------------------- 1 1 21 1 2 22 1 3 23 1 4 24 1 5 25 2 11 1 2 12 2 2 13 3 2 14 4 2 15 5 3 21 31 3 22 32 3 23 33 3 24 34 3 25 35 4 31 11 4 32 12 4 33 13 4 34 14 4 35 15
|
Privacy
Policy/Security Notice
NIST is an agency of the U.S.
Commerce Department.
Date created: 01/31/2015 |