Solved
New Contributor
Posts: 2

# Statistics

Hi there,

i have some very basic questions. I am working on my homework at the moment and our prof. gave us this code:

```PROC IML;

n = 50;

pi = 0.5;

alpha = 0.025;

DO i = 1 TO 10000;

X = RANBIN(1,n,pi);

p = x/n; var = p*(1-p);

b_l = p - PROBIT(1-alpha/2) * sqrt(var) / sqrt(n);

b_u = p + PROBIT(1-alpha/2) * sqrt(var) / sqrt(n);

d_l = pi < b_l; d_u = pi > b_u; data = data//(p||b_l||b_u||d_l||d_u);

END;

CREATE sim_binomial FROM data;

APPEND FROM data; QUIT;

PROC MEANS data=sim_binomial;

VAR COL1-COL5;

RUN;```

and this output:

we have to answer some questions about the output and code. I am not able to answer the following of them:

What describes  variable COL1 ?

Wich distribution does we use ? (Where can i see that ?)

What are the means of the confidence bounds ? (How do I calculate that?

I know that this are very easy questions for you, but they are very difficult for me.

Thank you so much !

Best Regards,

Tobias

Accepted Solutions
Solution
3 weeks ago
Posts: 1,256

## Re: Statistics

Posted in reply to Tobias1997

Hi Tobias and welcome to the SAS Support Communities!

Let me start with saying that I wish I'd been assigned homework like this, involving SAS, when I studied mathematics 25 years ago ...

I think, the answer to the second question will help you to answer the other two questions. So, let's tackle this first.

Even without being experts for PROC IML you and I can see that the first three statements after "PROC IML;" assign scalar numeric values to variables named n, pi and alpha. It is likewise obvious that the subsequent DO loop will iterate the statements X =..., p = ..., etc. until data = ... 10000 times. The assumption that all those values calculated during the 10000 iterations must be stored somewhere to make them available is confirmed by looking up the meaning of the // and || operators and the CREATE and APPEND statements in the IML documentation. More precisely, p, b_l, b_u, d_l and d_u end up as variables COL1, ..., COL5, respectively, in a SAS dataset named SIM_BINOMIAL, which has 10000 observations -- one from each iteration of the DO loop.

The name of this dataset gives you a strong hint as to which statistical distribution is primarily involved here. Actually, there are two different distributions involved, as you will see when you look up the RANBIN and PROBIT functions (which are used in the DO loop) in the SAS documentation.

Now think about what type of random experiment is associated with the first of these two statistical distributions and how the parameters n and pi as well as the result X (=x) of the RANBIN call relate to such an experiment. This together with the fact that COL1 contains the values x/n previously stored in variable p should help you to answer the first question.

Finally, how do (lower and upper) "confidence bounds" come into play? Well, can you spot the formula used for two of the variables calculated in the DO loop in this Wikipedia article? (Hint: l stands for "lower", u for "upper". Guess what b stands for.) The two variables in question are also contained in dataset SIM_BINOMIAL. Using the MEANS procedure, some descriptive statistics have already been computed for variables COL1, .., COL5, for example "Mittelwert" (English: mean). That is to say, you don't have to calculate them. They're already there.

I hope this helps. Please feel free to ask if something is still unclear.

Best regards from Germany,

Reinhard

All Replies
Solution
3 weeks ago
Posts: 1,256

## Re: Statistics

Posted in reply to Tobias1997

Hi Tobias and welcome to the SAS Support Communities!

Let me start with saying that I wish I'd been assigned homework like this, involving SAS, when I studied mathematics 25 years ago ...

I think, the answer to the second question will help you to answer the other two questions. So, let's tackle this first.

Even without being experts for PROC IML you and I can see that the first three statements after "PROC IML;" assign scalar numeric values to variables named n, pi and alpha. It is likewise obvious that the subsequent DO loop will iterate the statements X =..., p = ..., etc. until data = ... 10000 times. The assumption that all those values calculated during the 10000 iterations must be stored somewhere to make them available is confirmed by looking up the meaning of the // and || operators and the CREATE and APPEND statements in the IML documentation. More precisely, p, b_l, b_u, d_l and d_u end up as variables COL1, ..., COL5, respectively, in a SAS dataset named SIM_BINOMIAL, which has 10000 observations -- one from each iteration of the DO loop.

The name of this dataset gives you a strong hint as to which statistical distribution is primarily involved here. Actually, there are two different distributions involved, as you will see when you look up the RANBIN and PROBIT functions (which are used in the DO loop) in the SAS documentation.

Now think about what type of random experiment is associated with the first of these two statistical distributions and how the parameters n and pi as well as the result X (=x) of the RANBIN call relate to such an experiment. This together with the fact that COL1 contains the values x/n previously stored in variable p should help you to answer the first question.

Finally, how do (lower and upper) "confidence bounds" come into play? Well, can you spot the formula used for two of the variables calculated in the DO loop in this Wikipedia article? (Hint: l stands for "lower", u for "upper". Guess what b stands for.) The two variables in question are also contained in dataset SIM_BINOMIAL. Using the MEANS procedure, some descriptive statistics have already been computed for variables COL1, .., COL5, for example "Mittelwert" (English: mean). That is to say, you don't have to calculate them. They're already there.

I hope this helps. Please feel free to ask if something is still unclear.

Best regards from Germany,

Reinhard

New Contributor
Posts: 2

## Re: Statistics

Posted in reply to FreelanceReinhard

Hello Reinhard,

thank you very much !

I really appreciate your help. Now I understand my homework.

Best Regards,

Tobias

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
• 2 replies
• 98 views
• 0 likes
• 2 in conversation