Create Dataset with DSL (from Fraktal SAS Programming)
What is this?
There are numerous occasions where data are needed that are not available. 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 provides all means to generate data of unlimited variation in structure, size and precision.
This example will make use of three iteration concepts and two random number generators to produce a sample dataset with character, integer and floating-point columns.
|Code executed||Function performed|
||Initiate data step processing with a DATA statement supplying a name.|
||Start outer loop over discrete values given in comma separated list.|
||Start inner loop over integers given by start, end and increment.|
||Start branching over values from outer loop.|
||Assign uniform distribution random number generator to listed values.|
||Assign normal distribution random number generator to remainder of values.|
||End branching over values from outer loop.|
||Write current content of PDV to dataset 'random'.|
||Terminate inner loop.|
||Terminate outer loop.|
||End the data step run-group (use "cancel" for syntax check only).|
When issuing the phrase "vt random" in the command window of your SAS session, the generated table will pop-up in a "Viewtable Window". It's easy to recognize that random number properties have changed according to the algorithm coded: