The idea is this. You describe a random process, then build a model of it. You let it run a few (or many) times and you call the observations a "sample". With the sample, you calculate some estimates of parameters and you write those estimates into a summary file somewhere. Then you repeat the process, getting a new sample, some new estimates, and write them into the summary file. You do that over and over again, so the file is now holding the "sampling distribution" of the estimators.

Then you do some diagnostic work on the summary file. You can get the averages of your estimates, get histograms of them, and so forth. Then you can say, "given that my process operates, these are the likely results." That gives you a pretty rigorous understanding of the probabilty process.

SAS must be the world's easiest programming language. It does everything for you "implicitly" that must be formally specified in other programs. Furthermore, SAS doesn't require lots of braces or other separators. Suppose we want to draw normal random observations. In SAS, that means you run the function NORMAL(seed), where you put some number in place of the word "seed". Or, if you don't want to put in a number for "seed", you can just put in a zero, as in NORMAL(0), and the computer will use the time to seed your normal variable. If we want to draw 20 random observations, we could do this:

DATA A;
  DO I=1 to 20;  /*creates an integer variable I*/ 
  E=NORMAL(0);   /*it creates the variable E*/
  OUTPUT;
END;

If you put that in a file by itself, along with a "proc print", you would see a set of 20 numbers. Next, suppose you want this to repeat itself 10 times. What do you do? You put a DO loop around the DO loop, so it repeats itself.

DATA A;
  DO T=1 to 10;   /* this is the new "outer loop" */
    DO I=1 to 20; /*creates an integer variable I */
    E=NORMAL(0);  /* creates the variable E */
    OUTPUT;
  END;
END;         /*End corresponds to loop with T */

If you want to output the numbers and see the average of each of the variable, all you have to do is tack on the commands, say:

PROC PRINT;
PROC MEANS;
   VAR U; BY T;

-- PaulJohnson - 10 Dec 2002

 
|Powered by TWiki