/*This example generates a data set with one variable and 100 records
Each record contains a random number, generated from a uniform distribution, in the range [0:1].
The idea is to create a new data set with the mean value of all the records
START ADaMSoft, copy the script in the command editor window and press F8*/

dataset out=test;
newvar random_value=num;
for (int i=0; i<100; i++)
{
	random_value=RNDUNIFORM();
	output;
};
run;


Proc Univariate dict=Test out=mean;
var random_value;
statistic MEAN;
outstyle varrow;
run;

/*HOW IT WORKS:
*** Here a new data set is created, it's name will be "test"
dataset out=test;
*** A numerical variable is created, it's name is "random_value"
newvar random_value=num;
*** The operations between the brackets are repeated 100 times
for (int i=0; i<100; i++)
{
	*** The ADaMSoft function RNDUNIFORM() is called and it's return value is copied into the variable "random_value"
	random_value=RNDUNIFORM();
	*** here the record is written in the output data set
	output;
};
run;

*** Here it is simple called the PROC UNIVARIATE that reads the values from the data set TEST and creates the data set MEAN
Proc Univariate dict=Test out=mean;
var random_value;
statistic MEAN;
outstyle varrow;
run;
*/