<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Correct probability program in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Correct-probability-program/m-p/315843#M68940</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.Dice;
	ntrials=10000;
	array freq[12];

	do i=2 to 12;
		freq[i]=0;
	end;

	/* zero the freq array */
	do trials=1 to ntrials;
		roll=0;

		do j=1 to 2;
			roll + floor(uniform(0)*6+1);

			/* generate a random integer between 1 and 6 */
		end;
		freq[roll]+1;
	end;
	keep roll frequency probability;
	format roll 4. frequency nlnum16. probability nlnum10.6;
	label roll="Value Rolled" frequency="Frequency" probability="Probability";

	do roll=2 to 12;
		frequency=freq[roll];
		probability=frequency/ntrials;
		output;
	end;
	roll=.;
	frequency=ntrials;
	probability=1;
	output;
	title 'Rolling 2 dice 10000 times';

proc print noobs label;
end;


&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data e4;
seed=10000;
do i=1 to 1000;
sum=0;
do j= 1 to 5;
x =ranbin(seed,1,.5);
sum=sum+x;
end;
prop=sum/5;
drop i j sum seed x;
output e4;
end;
datalines;
axis length =4 in;
proc gchart data =e4;
vbar prop / type =pct raxis=axis maxis =axis;
run;

data e5;
seed=10000;
do i=1 to 1000;
sum=0;
do j= 1 to 10;
x =ranbin(seed,1,.75);
sum=sum+x;
end;
prop=sum/10;
drop i j sum seed x;
output e5;
end;
datalines;
axis length =4 in;
proc gchart data =e5;
vbar prop / type =pct raxis=axis maxis =axis;
run;

data e6;
seed=10000;
do i=1 to 1000;
sum=0;
do j= 1 to 20;
x =ranbin(seed,1,.95);
sum=sum+x;
end;
prop=sum/20;
drop i j sum seed x;
output e6;
end;
datalines;
axis length =4 in;
proc gchart data =e6;
vbar prop / type =pct raxis=axis maxis =axis;
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;Data simulal;
do j = 1 to 2000;
	do i = 1 to 5;
	sum=0;
	x[i]= 0+ 1*rannor(2452083);
    sum =sum+x;
    s=std(x[i]);
    avg=sum/5;
    y=s/avg;
    output;
    end;
end;

proc univariate data =simulal plot;
	title1 'Simulated Normal Variate';
    title2 'with Men 0 and Srandard Deviation 1';
    var x;
	var y;
run;

&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
    seed=123;
	sum=0;
    do i = 1 to 1000;
         x1=ranuni(seed);
		 x2=ranuni(seed);
        if .1&amp;lt;x1+x2&amp;lt;.3 then 	sum=sum+1;
		p = sum/1000;
       standard_error= sqrt(p*(1-p)/1000);
        end;
run;
proc freq data=one;
     table p/standard_error;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;1. When I make the porgram run, the title of the first code,Rolling 2 dice 10000 times, will be used for the second. Where I should rewrite to avoid it?&lt;/P&gt;&lt;P&gt;2. In the second code, where I can rewrite the code to change the interval scale of main axis?&lt;/P&gt;&lt;P&gt;3. In the third code,when I do the loop, I want to store every value of x and then get the average and the stadard deviation of them five times a round. Where I can rewrite?&lt;/P&gt;&lt;P&gt;4. In the forth code,I don't wnat the table; I just want to get p and&lt;CODE&gt; standard error. Where I can rewrite?&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Dec 2016 07:45:26 GMT</pubDate>
    <dc:creator>karen8169</dc:creator>
    <dc:date>2016-12-01T07:45:26Z</dc:date>
    <item>
      <title>Correct probability program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Correct-probability-program/m-p/315843#M68940</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.Dice;
	ntrials=10000;
	array freq[12];

	do i=2 to 12;
		freq[i]=0;
	end;

	/* zero the freq array */
	do trials=1 to ntrials;
		roll=0;

		do j=1 to 2;
			roll + floor(uniform(0)*6+1);

			/* generate a random integer between 1 and 6 */
		end;
		freq[roll]+1;
	end;
	keep roll frequency probability;
	format roll 4. frequency nlnum16. probability nlnum10.6;
	label roll="Value Rolled" frequency="Frequency" probability="Probability";

	do roll=2 to 12;
		frequency=freq[roll];
		probability=frequency/ntrials;
		output;
	end;
	roll=.;
	frequency=ntrials;
	probability=1;
	output;
	title 'Rolling 2 dice 10000 times';

proc print noobs label;
end;


&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data e4;
seed=10000;
do i=1 to 1000;
sum=0;
do j= 1 to 5;
x =ranbin(seed,1,.5);
sum=sum+x;
end;
prop=sum/5;
drop i j sum seed x;
output e4;
end;
datalines;
axis length =4 in;
proc gchart data =e4;
vbar prop / type =pct raxis=axis maxis =axis;
run;

data e5;
seed=10000;
do i=1 to 1000;
sum=0;
do j= 1 to 10;
x =ranbin(seed,1,.75);
sum=sum+x;
end;
prop=sum/10;
drop i j sum seed x;
output e5;
end;
datalines;
axis length =4 in;
proc gchart data =e5;
vbar prop / type =pct raxis=axis maxis =axis;
run;

data e6;
seed=10000;
do i=1 to 1000;
sum=0;
do j= 1 to 20;
x =ranbin(seed,1,.95);
sum=sum+x;
end;
prop=sum/20;
drop i j sum seed x;
output e6;
end;
datalines;
axis length =4 in;
proc gchart data =e6;
vbar prop / type =pct raxis=axis maxis =axis;
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;Data simulal;
do j = 1 to 2000;
	do i = 1 to 5;
	sum=0;
	x[i]= 0+ 1*rannor(2452083);
    sum =sum+x;
    s=std(x[i]);
    avg=sum/5;
    y=s/avg;
    output;
    end;
end;

proc univariate data =simulal plot;
	title1 'Simulated Normal Variate';
    title2 'with Men 0 and Srandard Deviation 1';
    var x;
	var y;
run;

&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
    seed=123;
	sum=0;
    do i = 1 to 1000;
         x1=ranuni(seed);
		 x2=ranuni(seed);
        if .1&amp;lt;x1+x2&amp;lt;.3 then 	sum=sum+1;
		p = sum/1000;
       standard_error= sqrt(p*(1-p)/1000);
        end;
run;
proc freq data=one;
     table p/standard_error;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;1. When I make the porgram run, the title of the first code,Rolling 2 dice 10000 times, will be used for the second. Where I should rewrite to avoid it?&lt;/P&gt;&lt;P&gt;2. In the second code, where I can rewrite the code to change the interval scale of main axis?&lt;/P&gt;&lt;P&gt;3. In the third code,when I do the loop, I want to store every value of x and then get the average and the stadard deviation of them five times a round. Where I can rewrite?&lt;/P&gt;&lt;P&gt;4. In the forth code,I don't wnat the table; I just want to get p and&lt;CODE&gt; standard error. Where I can rewrite?&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2016 07:45:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Correct-probability-program/m-p/315843#M68940</guid>
      <dc:creator>karen8169</dc:creator>
      <dc:date>2016-12-01T07:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: Correct probability program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Correct-probability-program/m-p/315982#M68978</link>
      <description>&lt;P&gt;First, instead of&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token function"&gt;floor&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;uniform&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;6&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token number"&gt;you would be better off using:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;rand(&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'table'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;1&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;/&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;6&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;1&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;/&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;6&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;1&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;/&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;6&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;1&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;/&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;6&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;1&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;/&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;6&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;1&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;/&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;6&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;The UNIFORM function has some known issues and the RAND function is a bit better. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;1) TITLE statements stay in effect until cleared. So if you do something like:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;&amp;nbsp;&amp;nbsp; Title "Some text";&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;code for procedure1&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;datastep&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;&amp;nbsp;&amp;nbsp; &amp;lt;code for procedure2&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;code for proceduren&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;The same title will appear with all output through procedure n. Use a blank title statement to clear.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;2) If you use Proc CHART then you create AXIS statements to define the characteristics such as numbers of tick marks, labels and fonts. Then inside the Proc Gchart reference the Axis in the raxis or maxis option. Often you have a separate axis definition for each. You can have at least up to AXIS99 for 99 concurrent definitions available. If you change to Proc SGPLOT then the YAXIS or Xaxis statements with different syntax perform the same function.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;3) there are a couple of different ways to interpret your request for this. Please provide a small example maybe 10 records of what you want the output to look like.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;4) You have a syntax error. I am not sure what you are requesting. Are you looking for an output data set of the frequencies of P and standard_error from data set one? If so you need to request each output set, one per variable from proc freq. Also data one only has one record as you did not include an output inside the do loop. Possibly you meant:&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="SAS Monospace" size="2"&gt;&lt;CODE class=" language-sas"&gt;data one;
   seed=123;
   sum=0;
   do i = 1 to 1000;
      x1=ranuni(seed);
      x2=ranuni(seed);
      if .1&amp;lt;x1+x2&amp;lt;.3 then 	sum=sum+1;
      p = sum/1000;
      standard_error= sqrt(p*(1-p)/1000);
      output;
   end;

run;
proc freq data=one noprint;
     tables p / out= FreqP;
     tables standard_error / out = FreqSe;
run;&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Dec 2016 15:44:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Correct-probability-program/m-p/315982#M68978</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-12-01T15:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Correct probability program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Correct-probability-program/m-p/316933#M69323</link>
      <description>&lt;P&gt;3.&lt;/P&gt;&lt;PRE&gt;	do i = 1 to 5;
	sum=0;
	x[i]= 0+ 1*rannor(2452083);
  &lt;/PRE&gt;&lt;P&gt;If I simulate the program, I want get 5 random numbers and 5 numbers are a group.&lt;/P&gt;&lt;P&gt;And then I want to get 2000 groups to calculate the average of each of them and then get the standard deviation.&lt;/P&gt;&lt;PRE&gt;Data simulal;
do j = 1 to 2000;
	do i = 1 to 5;
	sum=0;
	x[i]= 0+ 1*rannor(2452083);
    sum =sum+x;
    s=std(x[i]);
    avg=sum/5;
    y=s/avg;
    output;
    end;
end;

proc univariate data =simulal plot;
	title1 'Simulated Normal Variate';
    title2 'with Men 0 and Srandard Deviation 1';
    var x;
	var y;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Dec 2016 05:24:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Correct-probability-program/m-p/316933#M69323</guid>
      <dc:creator>karen8169</dc:creator>
      <dc:date>2016-12-06T05:24:39Z</dc:date>
    </item>
  </channel>
</rss>

