# Introduction to simulation with sas

#### katlego

##### New Member
Does anyone know any tutorial links for introduction to simulation with sas?

#### ledzep

##### Point Mass at Zero
There is so much resource up in the web.I would do a simple search in the web to get started with.
This is a good one:
http://www.biostat.umn.edu/~john-c/5421/notes.023b and UCLA website always have a good resource.

In fact, I would start from here.
(LINK)

While we are here, here's really some basic examples of simulation in SAS.
Code:
*Suppose you want to simulate 1000 values from a Normal distribution with mean 3 and standard deviation of 1.50;

/*Appraoch 1*/
data sim_data;
do i=1 to 1000;
x = 3 + rannor(0)*1.50;
output;
end;
run;

*check your outputs;
proc means data=sim_data;
var x;run;
Analysis Variable : x
N            Mean         Std Dev         Minimum         Maximum
-----------------------------------------------------------------
1000       2.9315496       1.5082780      -2.0852613       8.4886542
------------------------------------------------------------------
* The same can be done using a macro;
/*Appraoch2*/

%macro simulate (mean,sd) ;
data simulated_data;
do j = 1 to 1000 ;
x= &mean+rannor(0)*&sd;
output;
end;
run;
%mend ;
%simulate(3,1.50) ;

#### katlego

##### New Member
I really need a solid foundation for sas, so i was hoping that you will suggest several rich sas websites. I do not want to search the internet every time I need to solve a case study. All I want is several websites that will give me concrete syntax explanations. Nevertheless thanks for your suggestion.