<?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: proc means with by variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/322584#M71379</link>
    <description>&lt;P&gt;Since you originally asked about PROC MEANS, here is what it would look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc means data=have nway&amp;nbsp;noprint;&lt;/P&gt;
&lt;P&gt;var value;&lt;/P&gt;
&lt;P&gt;class id visit;&lt;/P&gt;
&lt;P&gt;output out=want (drop=_type_ _freq_) mean=average;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Jan 2017 04:12:38 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-01-05T04:12:38Z</dc:date>
    <item>
      <title>proc means with by variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/322548#M71365</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;I wonder how to code the proc means to calculate the &lt;STRONG&gt;avarage o&lt;/STRONG&gt;f the values by id and visit.&lt;/P&gt;
&lt;P&gt;example:&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 192pt;" border="0" width="256" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 48pt;" span="4" width="64" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl63" style="height: 15.0pt; width: 48pt;"&gt;&lt;STRONG&gt;id&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;&lt;STRONG&gt;visit&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;&lt;STRONG&gt;value&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" class="xl67" style="border-left: none; width: 48pt;"&gt;&lt;STRONG&gt;avarage&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;a&lt;/TD&gt;
&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;
&lt;TD rowspan="3" class="xl68"&gt;&lt;STRONG&gt;20&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;a&lt;/TD&gt;
&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl64" style="height: 15.0pt; border-top: none;"&gt;a&lt;/TD&gt;
&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl64" style="border-top: none; border-left: none;"&gt;30&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl65" style="height: 15.0pt; border-top: none;"&gt;a&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;50&lt;/TD&gt;
&lt;TD rowspan="2" class="xl68" style="border-top: none;"&gt;&lt;STRONG&gt;40&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl65" style="height: 15.0pt; border-top: none;"&gt;a&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;30&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl66" style="height: 15.0pt; border-top: none;"&gt;b&lt;/TD&gt;
&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;
&lt;TD rowspan="2" class="xl68" style="border-top: none;"&gt;&lt;STRONG&gt;15&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl66" style="height: 15.0pt; border-top: none;"&gt;b&lt;/TD&gt;
&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 00:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/322548#M71365</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2017-01-05T00:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: proc means with by variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/322552#M71366</link>
      <description>&lt;P&gt;Try proc sql&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id $	visit 	value ;
cards;
a 	1 	10 
a 	1 	20
a 	1 	30
a 	2 	50 
a 	2 	30
b 	1 	10 	
b 	1 	20
;

proc sql;
create table test as select *, mean(value) as average from have group by id ,visit;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Jan 2017 01:07:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/322552#M71366</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-01-05T01:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: proc means with by variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/322554#M71368</link>
      <description>&lt;P&gt;we could also get the same via data step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
do until(last.visit);
set have;
by id visit;
if first.visit then do;
s=value;
c=1;
end;
else do;
s+value;
c+1;
end;
average=s/c;
end;
do until(last.visit);
set have;
by id visit;
output;
end;
drop s c;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Jan 2017 01:18:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/322554#M71368</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-01-05T01:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: proc means with by variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/322555#M71369</link>
      <description>&lt;P&gt;Thank you very much for your prompt reply.&lt;/P&gt;
&lt;P&gt;It works!&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 01:23:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/322555#M71369</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2017-01-05T01:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: proc means with by variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/322584#M71379</link>
      <description>&lt;P&gt;Since you originally asked about PROC MEANS, here is what it would look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc means data=have nway&amp;nbsp;noprint;&lt;/P&gt;
&lt;P&gt;var value;&lt;/P&gt;
&lt;P&gt;class id visit;&lt;/P&gt;
&lt;P&gt;output out=want (drop=_type_ _freq_) mean=average;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 04:12:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/322584#M71379</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-05T04:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: proc means with by variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/322846#M71482</link>
      <description>&lt;P&gt;Thank you so much!! Astounding!!&lt;/P&gt;
&lt;P&gt;This is what exactly i want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Happy New year!!&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 23:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/322846#M71482</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2017-01-05T23:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: proc means with by variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/322915#M71507</link>
      <description>&lt;P&gt;&lt;BR /&gt;proc means data=have nway noprint ;&lt;BR /&gt;var value;&lt;BR /&gt;output out=test(drop=_TYPE_ _FREQ_)&lt;BR /&gt;mean= average;&lt;BR /&gt;class id visit ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this help&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 08:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/322915#M71507</guid>
      <dc:creator>pritam26</dc:creator>
      <dc:date>2017-01-06T08:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: proc means with by variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/323073#M71556</link>
      <description>&lt;P&gt;Thank you, pritam&lt;/P&gt;
&lt;P&gt;the solution is exactly the same as&amp;nbsp;&lt;SPAN&gt;Astounding's post.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I love it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 19:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-with-by-variables/m-p/323073#M71556</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2017-01-06T19:23:40Z</dc:date>
    </item>
  </channel>
</rss>

