PING
0.9
Statistical data handling and processing in production environment
|
Generate a dataset of random numbers generated with a uniform distribution U([0,1])
. A macro version of SAS ranuni
function.
dsn
: name of the output dataset;sampsize
: sample size, i.e. desired number of observations in the output dataset;a, b
: (option) constants used to define the alternative distribution U([a,b])
; if b
is set and not a
, then a=0
; if a
is set and not b
, then b=10
; default: neither a
, nor b
is set and only numbers ~ U([0,1])
are generated;seed
: (option) seed of the pseudo-random numbers generator; if seed<=0, the time of day is used to initialize the seed stream; default: seed=0
, i.e. a random seed is used;int
: (option) boolean flag (yes/no
) set to force integer numbers; default: int=no
;lib
: (option) name of the input library; by default: empty, i.e. WORK
is used;It will create the following variables, with size sampsize
, in the output dataset dsn
:
u
: uniformly distributed float numbers ~ U([0,1])
,x
: uniformly distributed float numbers ~ U([a,b])
if a
and/or b
are set,n
: integers uniformly distributed ~ U([a,b])
if a
and/or b
are set and int=yes
.while an index variable i
(sequence from 1 to sampsize
) is also kept.
The following commands:
allows us to generate (since we use a fixed seed >0
) the table TMP
of pseudo-random numbers below:
1 | u | n |
---|---|---|
1 | 0.1849625698 | 2 |
2 | 0.9700887157 | 10 |
3 | 0.3998243061 | 4 |
4 | 0.2593986454 | 2 |
5 | 0.9216025779 | 10 |
6 | 0.9692773498 | 10 |
7 | 0.5429791731 | 5 |
8 | 0.5316917228 | 5 |
9 | 0.0497940262 | 0 |
10 | 0.0665665516 | 0 |
See %_example_ranuni
for examples.
In short, this macro runs the following DATA step: