<?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: Average of multiple variables and also versions of them in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/733927#M228689</link>
    <description>&lt;P&gt;Here is a simple way to get the means from all possible subsets (except the empty subset):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input Ques fres tas mas des;
cards;
2 1 4 2 3
5 1 5 5 7
3 3 4 6 8
4 2 4 4 8
9 5 1 2 3
8 2 4 5 3
4 3 3 2 7
;

/* Get the number of all possible subsets except the empty subset */
data _null_;
set a;
array x _numeric_;
nbSets = 2 ** dim(x) - 1; 
call symputx("nbSets", nbSets);
stop;
run;

data want;
set a;
array x _numeric_;
array y {&amp;amp;nbSets.};
do s = 1 to &amp;amp;nbSets.;
    ss = s; sum = 0; nb = 0;
    do i = 1 by 1 until(ss = 0);
        if mod(ss, 2) = 1 then do;
            sum = sum + x{i};
            nb = nb + 1;
            end;
        ss = int(ss/2);
        end;
    y{s} = sum / nb;
    end;
drop s ss i sum nb;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I wouldn't try to scale this method beyond n=12.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Apr 2021 21:04:57 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2021-04-14T21:04:57Z</dc:date>
    <item>
      <title>Average of multiple variables and also versions of them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/733896#M228680</link>
      <description>&lt;P&gt;Hi SAS community,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the below dataset and need to calculate mean of all the variables possible with these 5 variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For ex: Mean(&lt;CODE class=" language-sas"&gt;Ques fres tas mas des)&amp;nbsp;and&amp;nbsp;Mean(Ques fres tas mas)&amp;nbsp;and&amp;nbsp;(Ques fres tas )...&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Is there a way to get the mean of all variations possible with these 5 variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input Ques fres tas mas des ;
cards;
2 1 4 2 3
5 1 5 5 7
3 3 4 6 8
4 2 4 4 8
9 5 1 2 3
8 2 4 5 3
4 3 3 2 7
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Let me know if this is possible .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your time and effort.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 19:16:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/733896#M228680</guid>
      <dc:creator>shasank</dc:creator>
      <dc:date>2021-04-14T19:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Average of multiple variables and also versions of them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/733909#M228685</link>
      <description>&lt;P&gt;Look at the SAS Functions Call AllComb in the documentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do realize this requires adding 26 variables to your data set? Hint: Comb function counts combinations of R elements from N choices. How are you going to keep track of which value is which set of variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before going into details what is the utility of this?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 20:06:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/733909#M228685</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-14T20:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: Average of multiple variables and also versions of them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/733910#M228686</link>
      <description>Thank you for your reply. Yes, I do realize that. The purpose of this is to&lt;BR /&gt;take a mean of all the combinations possible with these 5 variable and the&lt;BR /&gt;next step is to find the find the car combo with mean closest to a&lt;BR /&gt;different variable in another dataset.&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Apr 2021 20:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/733910#M228686</guid>
      <dc:creator>shasank</dc:creator>
      <dc:date>2021-04-14T20:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Average of multiple variables and also versions of them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/733927#M228689</link>
      <description>&lt;P&gt;Here is a simple way to get the means from all possible subsets (except the empty subset):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input Ques fres tas mas des;
cards;
2 1 4 2 3
5 1 5 5 7
3 3 4 6 8
4 2 4 4 8
9 5 1 2 3
8 2 4 5 3
4 3 3 2 7
;

/* Get the number of all possible subsets except the empty subset */
data _null_;
set a;
array x _numeric_;
nbSets = 2 ** dim(x) - 1; 
call symputx("nbSets", nbSets);
stop;
run;

data want;
set a;
array x _numeric_;
array y {&amp;amp;nbSets.};
do s = 1 to &amp;amp;nbSets.;
    ss = s; sum = 0; nb = 0;
    do i = 1 by 1 until(ss = 0);
        if mod(ss, 2) = 1 then do;
            sum = sum + x{i};
            nb = nb + 1;
            end;
        ss = int(ss/2);
        end;
    y{s} = sum / nb;
    end;
drop s ss i sum nb;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I wouldn't try to scale this method beyond n=12.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 21:04:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/733927#M228689</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-04-14T21:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: Average of multiple variables and also versions of them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/733968#M228694</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/110575"&gt;@shasank&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you for your reply. Yes, I do realize that. The purpose of this is to&lt;BR /&gt;take a mean of all the combinations possible with these 5 variable and the&lt;BR /&gt;next step is to find the find the car combo with mean closest to a&lt;BR /&gt;different variable in another dataset.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So what happens when you have the same mean for more than one of these combinations?&lt;/P&gt;
&lt;P&gt;If any of the variables are ever missing then the one of the choose 2 versions will always have the same mean as one of the single variable. More missing values per record means even more same mean values are likely.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 21:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/733968#M228694</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-14T21:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: Average of multiple variables and also versions of them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/733999#M228704</link>
      <description>That's a great point. Thank you for the critical thinking. My actual data is in a format if 11.11111 and doesn't have any missing values. The reason for this request is to find what combo of variables did an equipment use to get to a final number. The machine always uses a set of variable and I am trying to find a trend of which is the most used combo.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Apr 2021 00:24:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/733999#M228704</guid>
      <dc:creator>shasank</dc:creator>
      <dc:date>2021-04-15T00:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Average of multiple variables and also versions of them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/734000#M228705</link>
      <description>Thank you so so much for the solution. I am trying to modify this code to get the combination calculated as variable name. Is there a way to modify this code to get the combo variable used to get to the mean???</description>
      <pubDate>Thu, 15 Apr 2021 00:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/734000#M228705</guid>
      <dc:creator>shasank</dc:creator>
      <dc:date>2021-04-15T00:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Average of multiple variables and also versions of them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/734002#M228707</link>
      <description>&lt;P&gt;Get the combos with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data combos;
set a;
array x _numeric_;
length combo $160;
do set = 1 to &amp;amp;nbSets.;
    ss = set; combo = " ";
    do i = 1 by 1 until(ss = 0);
        if mod(ss, 2) = 1 then do;
            combo = catx("-", combo, vname(x{i}));
            end;
        ss = int(ss/2);
        end;
    output;
    end;
stop;
keep set combo;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Apr 2021 00:54:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/734002#M228707</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-04-15T00:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: Average of multiple variables and also versions of them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/734010#M228711</link>
      <description>Sorry for not being clear.&lt;BR /&gt;y{s} = sum / nb;&lt;BR /&gt;Instead of y1,y2,y3 is there a possibility to have the combo as a variable name. This would help know which all were combined to get to the value in the column.</description>
      <pubDate>Thu, 15 Apr 2021 01:43:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Average-of-multiple-variables-and-also-versions-of-them/m-p/734010#M228711</guid>
      <dc:creator>shasank</dc:creator>
      <dc:date>2021-04-15T01:43:10Z</dc:date>
    </item>
  </channel>
</rss>

