<?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: How to get the average value of a variable for every 5th row in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-average-value-of-a-variable-for-every-5th-row/m-p/127887#M34957</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;BR /&gt;do i=1 to 50;&lt;BR /&gt;output;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt; set have;&lt;BR /&gt; n=int((i-1)/5)+1;&lt;BR /&gt; proc print;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Mar 2013 18:27:51 GMT</pubDate>
    <dc:creator>Linlin</dc:creator>
    <dc:date>2013-03-05T18:27:51Z</dc:date>
    <item>
      <title>How to get the average value of a variable for every 5th row</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-average-value-of-a-variable-for-every-5th-row/m-p/127886#M34956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a file with over 43000 unique rows&amp;nbsp; which has a variable called model, I would like to get the average of this variable model for every fifth row.&lt;/P&gt;&lt;P&gt;I also have the file number indexed from 1 to 43000 but I am stuggling to get it to average it. I would even appreciate help with how to code every row into the same group by creating a new headin as then I could get the means by selecting unique group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The file currently looks like;&lt;/P&gt;&lt;P&gt;position&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; model&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n&lt;/P&gt;&lt;P&gt;483_1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.1234&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;678_1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.2345&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;876_1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.1456&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you! &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 18:10:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-average-value-of-a-variable-for-every-5th-row/m-p/127886#M34956</guid>
      <dc:creator>purfield</dc:creator>
      <dc:date>2013-03-05T18:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the average value of a variable for every 5th row</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-average-value-of-a-variable-for-every-5th-row/m-p/127887#M34957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;BR /&gt;do i=1 to 50;&lt;BR /&gt;output;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt; set have;&lt;BR /&gt; n=int((i-1)/5)+1;&lt;BR /&gt; proc print;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 18:27:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-average-value-of-a-variable-for-every-5th-row/m-p/127887#M34957</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2013-03-05T18:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the average value of a variable for every 5th row</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-average-value-of-a-variable-for-every-5th-row/m-p/127888#M34958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure I understand the question fully but would something like this do what you want :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc means data=MyData(where=(mod(n,5)=0));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var model;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 18:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-average-value-of-a-variable-for-every-5th-row/m-p/127888#M34958</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-03-05T18:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the average value of a variable for every 5th row</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-average-value-of-a-variable-for-every-5th-row/m-p/127889#M34959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think we are all getting to the same point ... but here is my version:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test3;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if n = 1 then cat = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; group = mod(n,5);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if group = 1 then cat + 1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the group variable is basically providing an indicator for every 5th observation. The cat variable is categorizing the group of 5 observations (1-5 cat 1 , 6 - 10 cat2 , etc...).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wasnt clear if you are average the five observations (average obs 1 through 5, 6 through 10, etc... which would be over 8000 averages) or eliminate all but every 5th obs and average those obs for an outcome of one number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway .. hope this helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 18:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-average-value-of-a-variable-for-every-5th-row/m-p/127889#M34959</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2013-03-05T18:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the average value of a variable for every 5th row</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-average-value-of-a-variable-for-every-5th-row/m-p/127890#M34960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to everyone for their help, that worked perfectly!first time posting in a forum and was great to get such answers!&lt;/P&gt;&lt;P&gt;Thank you! &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Mar 2013 14:27:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-average-value-of-a-variable-for-every-5th-row/m-p/127890#M34960</guid>
      <dc:creator>purfield</dc:creator>
      <dc:date>2013-03-06T14:27:57Z</dc:date>
    </item>
  </channel>
</rss>

