New Contributor
Posts: 2

# Simulation data using SAS

How do I code my sas prog. to solve this problem?

I trying to comparing correlated means in the presence of incomplete data (Task) using simulated data

I've tried to perform this task using simulated date - statistical power cal.

Compute the empirical size and power calculation using 1000 data sets and significance level of α = 0:05. Under the alternative hypotheses   is varied among 0 and 1.0, and the correlation  is varied among ρ =  0.2 and 0.9.

1. Simulation1

Generate from Exponential distribution with scale parameter = 1; using  np = 20, nux = 10, and nuy = 25

1. Simulation 2

Generate from normal distribution using  np = 20, nux = 30, and nuy = 10

• Simulation 3

Generate from normal distribution using  np = 10, nux = 15, and nuy = 5

Where np represent the number of complete pairs where both observations (x; y) are present, nux is the number of unpaired observations where only the first value (x) is present

and nuy is the number of unpaired observations where only the second value (y) is present.

Figure 4 – Two Correlated Normally Distributed Variables
Data Example4;
call streaminit(5678);
keep x y;
mu1=10; mu2=20; var1=4; var2=9; rho=.5;
do i = 1 to 1000;
x = rand("Normal", 0,1);
y = rho*x+sqrt(1-rho**2)*rand("Normal",0,1);
x = mu1 + sqrt(var1)*x;
y = mu2 + sqrt(var2)*y;
output;
end;
run

Posts: 4,736

## Re: Simulation data using SAS

@collbb1

You will most likely have to ask a more specific question than How do I code my sas prog. to get an answer.

New Contributor
Posts: 2

## Re: Simulation data using SAS

Thanks, Need to know how to set up sas code to simulate dat

Compute the empirical size and power calculation using 1000 data sets and significance level of α = 0:05. Under the alternative hypotheses is varied among 0 and 1.0, and the correlation is varied among ρ = 0.2 and 0.9.

Simulation1

Generate from Exponential distribution with scale parameter = 1; using np = 20, nux = 10, and nuy = 25

Where np represent the number of complete pairs where both observations (x; y) are present, nux is the number of unpaired observations where only the first value (x) is present

and nuy is the number of unpaired observations where only the second value (y) is present

SAS Super FREQ
Posts: 4,240

## Re: Simulation data using SAS

It sounds like you are looking for resources and sample code. Rather than answer your specific questions, here are some links that you might find useful:

Start by reading "Simulation in SAS: The slow way or the BY way" to learn the general structure of simulation code.

To learn how to simulate multivariate normal data in SAS, see "Sampling from the multivariate normal distribution" and "How to generate multiple samples from the multivariate normal distribution in SAS".  If you don't have SAS/IML, you can use PROC SIMNORMAL. For 2-D data or for nonnormal data, you can use the DATA step, as you are doing in your post.

For power estimation using simulation, see "Using simulation to estimate the power of a statistical test."

For more information, see "Ten Tips for Simulating Data with SAS", which includes an example of using simulations to estimate power. For many more examples and details, see Simulating Data with SAS.

Discussion stats
• 3 replies
• 175 views
• 0 likes
• 3 in conversation