<?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 Re: Question about Loops in SAS in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Question-about-Loops-in-SAS/m-p/181325#M46180</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Naveen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the help. The first part (generating 2000 sets of 100 random values) is what I need, and I was able to solve the second part. In short, the final code would look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data rand;&lt;/P&gt;&lt;P&gt;call streaminit(-1);&lt;/P&gt;&lt;P&gt;do j=1 to 2000; /*modified here*/&lt;/P&gt;&lt;P&gt;do i = 1 to 100;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; x = rand("Normal")*5+1;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end; /*modified here*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc means noprint data=rand;&lt;/P&gt;&lt;P&gt;by j; /*modified here*/&lt;/P&gt;&lt;P&gt;output out=Rand_means (drop=_type_ _freq_) /*modified here*/&lt;/P&gt;&lt;P&gt;mean(x)=A1; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kevin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Dec 2013 12:25:45 GMT</pubDate>
    <dc:creator>jassman1982</dc:creator>
    <dc:date>2013-12-24T12:25:45Z</dc:date>
    <item>
      <title>Question about Loops in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Question-about-Loops-in-SAS/m-p/181322#M46177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am new to SAS and would like to accomplish the following task: the first one creates 100 variables, the second code piece takes the average of the 100 values (call this variable A1). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question: I wish to repeat this 2000 times, so that I have a dataset of 2000 observations of A1, but I don't know how to modify the code...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt; rand;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt; streaminit(-&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt; i = &lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;to&lt;/SPAN&gt; &lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;100&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; x = rand(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;"Normal"&lt;/SPAN&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;)*&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;+&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;means&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;noprint&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;=rand;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;output&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;out&lt;/SPAN&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;=rand (drop=_type_ _freq_) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;mean&lt;/SPAN&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;(x)=A1; &lt;/SPAN&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Dec 2013 08:26:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Question-about-Loops-in-SAS/m-p/181322#M46177</guid>
      <dc:creator>jassman1982</dc:creator>
      <dc:date>2013-12-24T08:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Question about Loops in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Question-about-Loops-in-SAS/m-p/181323#M46178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First thing, i did not understand the clear objective of your question. If you can give expected dataset example, it will be very much helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, as you said you are new to SAS, following is what i presume you want to do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set rand;&lt;/P&gt;&lt;P&gt;do i = 1 to 2000;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop i;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Dec 2013 08:49:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Question-about-Loops-in-SAS/m-p/181323#M46178</guid>
      <dc:creator>JatinBansal</dc:creator>
      <dc:date>2013-12-24T08:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: Question about Loops in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Question-about-Loops-in-SAS/m-p/181324#M46179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First off, If you are taking &lt;STRONG&gt;mean(X),&lt;/STRONG&gt; how can you expect 2000 values(observations) in your output A1 of proc means step. Please clarify&lt;/P&gt;&lt;P&gt;Did you mean -&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: navy; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt; rand;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt; streaminit(-&lt;/SPAN&gt;&lt;SPAN style="background: white; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;do j=1 to 2000; /*modified here, is this what you want?*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt; i = &lt;/SPAN&gt;&lt;SPAN style="background: white; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;to&lt;/SPAN&gt; &lt;SPAN style="background: white; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;STRONG&gt;100&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; x = rand(&lt;/SPAN&gt;&lt;SPAN style="background: white; color: purple; font-family: 'Courier New'; font-size: 10pt;"&gt;"Normal"&lt;/SPAN&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;)*&lt;/SPAN&gt;&lt;SPAN style="background: white; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;+&lt;/SPAN&gt;&lt;SPAN style="background: white; color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: navy; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: navy; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="background: white; color: navy; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;STRONG&gt;means&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;noprint&lt;/SPAN&gt; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;=rand;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;output&lt;/SPAN&gt; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;out&lt;/SPAN&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;=rand (drop=_type_ _freq_) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;mean&lt;/SPAN&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;(x)=A1; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: navy; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; font-family: 'Courier New'; font-size: 10pt;"&gt;Naveen&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Dec 2013 09:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Question-about-Loops-in-SAS/m-p/181324#M46179</guid>
      <dc:creator>NaveenSrinivasan</dc:creator>
      <dc:date>2013-12-24T09:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Question about Loops in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Question-about-Loops-in-SAS/m-p/181325#M46180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Naveen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the help. The first part (generating 2000 sets of 100 random values) is what I need, and I was able to solve the second part. In short, the final code would look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data rand;&lt;/P&gt;&lt;P&gt;call streaminit(-1);&lt;/P&gt;&lt;P&gt;do j=1 to 2000; /*modified here*/&lt;/P&gt;&lt;P&gt;do i = 1 to 100;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; x = rand("Normal")*5+1;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end; /*modified here*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc means noprint data=rand;&lt;/P&gt;&lt;P&gt;by j; /*modified here*/&lt;/P&gt;&lt;P&gt;output out=Rand_means (drop=_type_ _freq_) /*modified here*/&lt;/P&gt;&lt;P&gt;mean(x)=A1; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kevin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Dec 2013 12:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Question-about-Loops-in-SAS/m-p/181325#M46180</guid>
      <dc:creator>jassman1982</dc:creator>
      <dc:date>2013-12-24T12:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Question about Loops in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Question-about-Loops-in-SAS/m-p/181326#M46181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;It rather looks much too simple and so I'm afraid perhaps my understanding could be wrong somewhere wrong. Is this what you really want?&lt;/P&gt;&lt;P&gt;data rand;&lt;/P&gt;&lt;P&gt;call streaminit(-1);&lt;/P&gt;&lt;P&gt;do j=1 to 2000; /*modified here*/&lt;/P&gt;&lt;P&gt;do i = 1 to 100;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; x = rand("Normal")*5+1;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop i;&lt;STRONG&gt; /*modified here*/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;Create table Rand_means as&lt;/P&gt;&lt;P&gt;Select&lt;/P&gt;&lt;P&gt;j, mean(x) as A1&lt;/P&gt;&lt;P&gt;from rand&lt;/P&gt;&lt;P&gt;group by j;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please correct my understanding. Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Merry Christmas,&lt;/P&gt;&lt;P&gt;Naveen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Dec 2013 14:01:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Question-about-Loops-in-SAS/m-p/181326#M46181</guid>
      <dc:creator>NaveenSrinivasan</dc:creator>
      <dc:date>2013-12-24T14:01:59Z</dc:date>
    </item>
  </channel>
</rss>

