BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tobias1997
Calcite | Level 5

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:

Screenshot_16.png

 

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. 

Can anybody please help me out ?

Thank you so much !

Best Regards,

Tobias

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

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

Tobias1997
Calcite | Level 5

Hello Reinhard,

 

thank you very much !

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

 

Best Regards,

Tobias

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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