Create Dataset with DSL (from Fraktal SAS Programming)

Aus phenixxenia.org
Zur Navigation springen Zur Suche springen

Zurück

Übersicht

Vorwärts

What is this?

There are many occasions when data are needed that are not really present. Think of a particular test scenario for generic report design or a series of artificial datasets used to test a specific algorithm.

Representing a fully featured 3rd generation programming language, SAS DSL offers all means to generate data of unlimited variation in structure, size and precision.

This example will make use of iteration and two random number generators to produce a sample dataset with character, integer and floating-point columns.


Documented Code

Code executed Function performed
data random;
Initiate data step processing with a DATA statement and a name
do group = 'A','B','C','D','X','Y','Z';
Start outer loop over discrete values given in comma separated list
do seed = 1 to 1000 by 1;
Start inner loop over integers given by start, end and increment
select (group);
Start branching over values from outer loop
when ('A','B','C','D')
noise = ranuni(pass);
Assign uniform distribution random number generator to listed values
otherwise
noise = normal(pass);
Assign normal distribution random number generator to remainder of values
end;
End branching over values from outer loop
output;
Write current content of PDV to dataset 'random'
end;
Terminate inner loop
end;
Terminate outer loop
run;
Terminate the data step


Results

Zurück

Übersicht

Vorwärts