Create Dataset with DSL (from Fraktal SAS Programming): Unterschied zwischen den Versionen

Aus phenixxenia.org
Zur Navigation springen Zur Suche springen
(Die Seite wurde neu angelegt: „Kategorie:zazy {{SeitenNavigation1 |hoch=Duck_zazy_com.png |links=xx_left.png |rechts=xx_right.png |übersicht=Data Step Programming (from Fraktal SAS Prog…“)
 
K
 
(14 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 5: Zeile 5:
 
|rechts=xx_right.png
 
|rechts=xx_right.png
 
|übersicht=Data Step Programming (from Fraktal SAS Programming)
 
|übersicht=Data Step Programming (from Fraktal SAS Programming)
|zurück=Read Text File (from Fraktal SAS Programming)
+
|zurück=Process Data using DSL (from Fraktal SAS Programming)
|vorwärts=Process Data (from Fraktal SAS Programming)
+
|vorwärts=Read Text File 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.
 +
 +
 +
== Documented Code ==
 +
 +
{| class="wikitable"
 +
|-
 +
! Code executed
 +
! Function performed
 +
|-
 +
|
 +
;data random;
 +
|Initiate data step processing with a DATA statement supplying 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(seed);
 +
|Assign uniform distribution random number generator to listed values.
 +
|-
 +
|
 +
:otherwise
 +
:noise = normal(seed);
 +
|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 <cancel>;
 +
|End the data step run-group (use ''"cancel"'' for syntax check only).
 +
|}
 +
 +
 +
== Results ==
 +
 +
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:
 +
 +
{| class="wikitable"
 +
|-
 +
!group
 +
!seed
 +
!noise
 +
|-
 +
|D||995||0.94102
 +
|-
 +
|D||996||0.27041
 +
|-
 +
|D||997||0.86849
 +
|-
 +
|D||998||0.40269
 +
|-
 +
|D||999||0.47663
 +
|-
 +
|D||1000||0.63694
 +
|-
 +
|X||1||0.82346
 +
|-
 +
|X||2||-1.04528
 +
|-
 +
|X||3||2.59510
 +
|-
 +
|X||4||-1.61314
 +
|-
 +
|X||5||0.78804
 +
|-
 +
|}
  
 
{{SeitenNavigation1
 
{{SeitenNavigation1
Zeile 15: Zeile 112:
 
|rechts=xx_right.png
 
|rechts=xx_right.png
 
|übersicht=Data Step Programming (from Fraktal SAS Programming)
 
|übersicht=Data Step Programming (from Fraktal SAS Programming)
|zurück=Read Text File (from Fraktal SAS Programming)
+
|zurück=Process Data using DSL (from Fraktal SAS Programming)
|vorwärts=Process Data (from Fraktal SAS Programming)
+
|vorwärts=Read Text File with DSL (from Fraktal SAS Programming)
 
}}
 
}}

Aktuelle Version vom 4. August 2014, 16:28 Uhr

Zurück

Übersicht

Vorwärts

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.


Documented Code

Code executed Function performed
data random;
Initiate data step processing with a DATA statement supplying 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(seed);
Assign uniform distribution random number generator to listed values.
otherwise
noise = normal(seed);
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 <cancel>;
End the data step run-group (use "cancel" for syntax check only).


Results

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:

group seed noise
D 995 0.94102
D 996 0.27041
D 997 0.86849
D 998 0.40269
D 999 0.47663
D 1000 0.63694
X 1 0.82346
X 2 -1.04528
X 3 2.59510
X 4 -1.61314
X 5 0.78804

Zurück

Übersicht

Vorwärts