draw_(X;Y)

Returns a random number using a given seed that remains persistent (sticky) even after selections or links with expansion are used.

Syntax

draw_(X;Y)

Input

Argument Type Description
X integer A scalar value

X is the seed

Y integer A scalar value

If Y is 0, then random decimal numbers between 0.0 and 1.0 are drawn; otherwise, random integers between 0 and Y-1 are drawn.

Return Value

A random number is drawn, with replacement, for each row. If Y is 0, then random decimal numbers between 0.0 and 1.0 are drawn; otherwise, random integers between 0 and Y-1 are drawn.

If the current table has only one segment or is a tabulation, then Y may also be negative; in this case |Y| must be greater than or equal to the number of selected rows, and random integers between 0 and |Y|-1 are drawn without replacement.

If X or Y is N/A, an error is returned.

Note: draw_(X;Y) will work correctly even when selections or links with expansion (expand="1") are used because the results are sticky. This means that the random number generated by the function for each row will be the same after the expansion. When the draw(X;Y) function is used, a different random number will be generated for each of the expanded rows.

Example

The following example illustrates the difference between using draw_(X;Y) and draw(X;Y) example.

<base table="pub.demo.retail.item"/>
<willbe name="sticky" value="draw_(8572;0)"/>
<willbe name="not_sticky" value="draw(8572;0)"/>
<sel value="2" expand="1"/>

The sticky column uses the draw_(X;Y) function, and the not_sticky column uses the draw(X;Y)function.

When the <sel> operation is run, the expanded rows in the sticky column have the same value. In the not_sticky column, the values in the expanded rows are different.