<?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: Howto group multiple variables and  calculating mean withthe help of PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542058#M149772</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236770"&gt;@shanky_44&lt;/a&gt;&amp;nbsp; &amp;nbsp;Are you after this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
input SUBJID        TRT     :$15.             val    ;*      mean_value;
cards;
10001        Screening            2.3
10001        Screening            3.6         
10001        Week24               2.3
10001         Week24              3.6
10002          Week24              3.6
10002          Screening           3.6
10002          Screening            3.6
10002          Week24              2.3
10003          Screening          2.3
10003          Screening          2.3
10003           Week24            2.3
10003          Week24             3.6
;

proc sql;
create table want as
select *,mean(val) as mean_value
from have
group by  SUBJID,TRT;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 11 Mar 2019 15:13:15 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-03-11T15:13:15Z</dc:date>
    <item>
      <title>Howto group multiple variables and  calculating mean withthe help of PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542039#M149762</link>
      <description>&lt;P&gt;Hello everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have one data set with more than 30 variables. I am mentioning her only three of them for reference. I want to group SUBJID, TRT and mean value of VAlL which would be a new variable and have to keep other variables in data-set. i tried Proc sql but getting error while &lt;STRONG&gt;mentioning other variables&lt;/STRONG&gt;. Imp point, I h&lt;STRONG&gt;ave to group SUBJID and TRT&lt;/STRONG&gt;.&amp;nbsp; Please help me out with this issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;SUBJID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TRT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; val&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mean_value&lt;/P&gt;&lt;P&gt;10001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Screening&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.3&lt;/P&gt;&lt;P&gt;10001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Screening&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;10001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Week24&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2.3&lt;/P&gt;&lt;P&gt;10001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Week24&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.6&lt;/P&gt;&lt;P&gt;10002&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Week24&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.6&lt;/P&gt;&lt;P&gt;10002&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Screening&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 3.6&lt;/P&gt;&lt;P&gt;10002&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Screening&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.6&lt;/P&gt;&lt;P&gt;10002&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Week24&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.3&lt;/P&gt;&lt;P&gt;10003&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Screening&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;2.3&lt;/P&gt;&lt;P&gt;10003&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Screening&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;2.3&lt;/P&gt;&lt;P&gt;10003&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Week24&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;2.3&lt;/P&gt;&lt;P&gt;10003&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Week24&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3.6&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SUBJID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TRT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;mean_value&lt;/P&gt;&lt;P&gt;10001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Screening&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Week24&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4.1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;10002&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Week24&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Screening&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;10003&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Screening&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Week24&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 14:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542039#M149762</guid>
      <dc:creator>shanky_44</dc:creator>
      <dc:date>2019-03-11T14:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Howto group multiple variables and  calculating mean withthe help of PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542044#M149765</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;i tried Proc sql but getting error while&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;mentioning other variables&lt;/STRONG&gt;&lt;SPAN&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Show us the SAS Log (the entire PROC SQL part of the log, not just the errors). Click on the {i} icon and paste the Log into the window that appears DO NOT SKIP THIS STEP&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 15:00:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542044#M149765</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-11T15:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Howto group multiple variables and  calculating mean withthe help of PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542050#M149767</link>
      <description>&lt;P&gt;&amp;nbsp;1. And I have no clue how you got the mean_Value of 4.1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;2. Your output rather looks like a report than a dataset???&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 15:06:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542050#M149767</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-11T15:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: Howto group multiple variables and  calculating mean withthe help of PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542051#M149768</link>
      <description>&lt;P&gt;Hi PaigeMiller,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am really sorry, I didn't have access to the same system where I was working. I posted here, to understand how to group multiple variables while doing calculation along keeping n number of variables.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 15:07:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542051#M149768</guid>
      <dc:creator>shanky_44</dc:creator>
      <dc:date>2019-03-11T15:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Howto group multiple variables and  calculating mean withthe help of PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542052#M149769</link>
      <description>&lt;P&gt;PROC SUMMARY will do this calculating of the mean within groups, for many variables and different group variables.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 15:09:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542052#M149769</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-11T15:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Howto group multiple variables and  calculating mean withthe help of PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542053#M149770</link>
      <description>&lt;P&gt;Please don't consider values as accurate calculation that part is just for reference. Basically I have to perform mean on val variable and create new variable keeping mean value. I have to keep this in a dataset.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 15:10:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542053#M149770</guid>
      <dc:creator>shanky_44</dc:creator>
      <dc:date>2019-03-11T15:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Howto group multiple variables and  calculating mean withthe help of PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542057#M149771</link>
      <description>&lt;P&gt;Thanks, I will try this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 15:12:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542057#M149771</guid>
      <dc:creator>shanky_44</dc:creator>
      <dc:date>2019-03-11T15:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Howto group multiple variables and  calculating mean withthe help of PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542058#M149772</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236770"&gt;@shanky_44&lt;/a&gt;&amp;nbsp; &amp;nbsp;Are you after this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
input SUBJID        TRT     :$15.             val    ;*      mean_value;
cards;
10001        Screening            2.3
10001        Screening            3.6         
10001        Week24               2.3
10001         Week24              3.6
10002          Week24              3.6
10002          Screening           3.6
10002          Screening            3.6
10002          Week24              2.3
10003          Screening          2.3
10003          Screening          2.3
10003           Week24            2.3
10003          Week24             3.6
;

proc sql;
create table want as
select *,mean(val) as mean_value
from have
group by  SUBJID,TRT;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Mar 2019 15:13:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542058#M149772</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-11T15:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Howto group multiple variables and  calculating mean withthe help of PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542078#M149779</link>
      <description>&lt;P&gt;I have one more question, if I have to keep n number of variables in data set. As In this example I have mentioned only 3 but I have more than 30 variables in my data set.&amp;nbsp; How should I mention all variables. You can consider other variables a,b,c,d.Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 15:34:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542078#M149779</guid>
      <dc:creator>shanky_44</dc:creator>
      <dc:date>2019-03-11T15:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Howto group multiple variables and  calculating mean withthe help of PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542080#M149780</link>
      <description>&lt;P&gt;Select *&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The&lt;STRONG&gt; * asterisk&lt;/STRONG&gt; will take care of that&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In essence, it means &lt;EM&gt;&lt;STRONG&gt;select all columns (select *), calculate the mean, remerge the mean value to all obs in each by group&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH &amp;amp; Regards!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 15:36:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542080#M149780</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-11T15:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: Howto group multiple variables and  calculating mean withthe help of PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542083#M149781</link>
      <description>&lt;P&gt;Thank you so much.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 15:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Howto-group-multiple-variables-and-calculating-mean-withthe-help/m-p/542083#M149781</guid>
      <dc:creator>shanky_44</dc:creator>
      <dc:date>2019-03-11T15:41:04Z</dc:date>
    </item>
  </channel>
</rss>

