<?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: MEAN(OF  X1-X12) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/MEAN-OF-X1-X12/m-p/751366#M236518</link>
    <description>&lt;P&gt;All of these difficulties are avoided if you have a long data set instead of a wide data set. Such as ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input id x;
    cards;
1 243
2 333
3 87
...
;
proc summary data=have;
    var x;
    output out=want sum=sum stddev=s;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and it's less typing. which means less chance for typographical errors or naming errors. and the code still works if you have a 13th data point (or a 14th data point or ...)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Jun 2021 22:16:18 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-06-30T22:16:18Z</dc:date>
    <item>
      <title>MEAN(OF  X1-X12)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MEAN-OF-X1-X12/m-p/751268#M236467</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;What is wrong with this code to calculate mean and std?&lt;/P&gt;
&lt;P&gt;error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Alphabetic prefixes for enumerated variables (X1_Sum-X12_sum) are different.&lt;BR /&gt;ERROR 71-185: The MEAN function call does not have enough arguments.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data wanted;
set have;
X1_avg12=mean(OF X1_sum-X12_SUM);
X1_std12=std(OF X1_sum-X12_SUM);
Run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Jun 2021 14:28:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MEAN-OF-X1-X12/m-p/751268#M236467</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-30T14:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: MEAN(OF  X1-X12)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MEAN-OF-X1-X12/m-p/751273#M236469</link>
      <description>&lt;P&gt;The SUM you have at the end of the variable names means that they are not sequentially numbered. List like x1-x12 have to end in numbers (and have no gaps in the numbering).&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 14:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MEAN-OF-X1-X12/m-p/751273#M236469</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-30T14:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: MEAN(OF  X1-X12)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MEAN-OF-X1-X12/m-p/751275#M236471</link>
      <description>&lt;P&gt;You have this:&lt;/P&gt;
&lt;P&gt;X1_SUM-X12_SUM where the index is not the last part of the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it was this, it would work as expected:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;X_SUM1-X_SUM12&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try the format of &lt;STRONG&gt;firstVariable--secondVariable&lt;/STRONG&gt; which will select all variables in between the first variable and the last variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data wanted;
set have;

X1_avg12 = mean(OF X1_sum--X12_SUM);
X1_std12 = std(OF X1_sum--X12_SUM);

Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a reference that illustrates how to refer to variables and datasets in a short cut list:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;What is wrong with this code to calculate mean and std?&lt;/P&gt;
&lt;P&gt;error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Alphabetic prefixes for enumerated variables (X1_Sum-X12_sum) are different.&lt;BR /&gt;ERROR 71-185: The MEAN function call does not have enough arguments.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data wanted;
set have;
X1_avg12=mean(OF X1_sum-X12_SUM);
X1_std12=std(OF X1_sum-X12_SUM);
Run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 14:44:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MEAN-OF-X1-X12/m-p/751275#M236471</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-30T14:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: MEAN(OF  X1-X12)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MEAN-OF-X1-X12/m-p/751280#M236474</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;What is wrong with this code to calculate mean and std?&lt;/P&gt;
&lt;P&gt;error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Alphabetic prefixes for enumerated variables (X1_Sum-X12_sum) are different.&lt;BR /&gt;ERROR 71-185: The MEAN function call does not have enough arguments.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data wanted;
set have;
X1_avg12=mean(OF X1_sum-X12_SUM);
X1_std12=std(OF X1_sum-X12_SUM);
Run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What's wrong?&amp;nbsp; The problem is the way that you named those "sum" variables.&amp;nbsp; &amp;nbsp;Can you back up a step and change the code that is creating X1_SUM and instead name it something like SUM_X1 or X_SUM1 where the numeric suffix is an actual &lt;STRONG&gt;suffix&lt;/STRONG&gt;?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 14:59:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MEAN-OF-X1-X12/m-p/751280#M236474</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-30T14:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: MEAN(OF  X1-X12)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MEAN-OF-X1-X12/m-p/751284#M236478</link>
      <description>&lt;P&gt;Here's the link to the documentation on&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p08ywlo51p6ezbn1lde9f0aphq6r.htm" target="_self"&gt;SAS Variable Lists&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You might want to try using a &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/n056thbq7p4e64n1ekde7e5yur7a.htm#n19m1fjlm50m53n1da5draaugc7d" target="_self"&gt;Variable Name Range List&lt;/A&gt;. Just make sure you are real careful.&lt;BR /&gt;&lt;BR /&gt;Here's an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data got ;
	infile cards ;
	input x1_sum x2_sum x5_sum x3_sum ;
	mySum=sum(of x1_sum--x5_sum) ;
	put _all_ ;
cards ;
1 2 3 4
2 3 4 5
3 4 5 6
;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And the SAS Log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;68   data got ;
69       infile cards ;
70       input x1_sum x2_sum x5_sum x3_sum ;
71       mySum=sum(of x1_sum--x5_sum) ;
72       put _all_ ;
73   cards ;

x1_sum=1 x2_sum=2 x5_sum=3 x3_sum=4 mySum=6 _ERROR_=0 _N_=1
x1_sum=2 x2_sum=3 x5_sum=4 x3_sum=5 mySum=9 _ERROR_=0 _N_=2
x1_sum=3 x2_sum=4 x5_sum=5 x3_sum=6 mySum=12 _ERROR_=0 _N_=3
NOTE: The data set WORK.GOT has 3 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


77   ;
78   run ;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notice how it is summing only x1_sum, x2_sum and x5_sum and not including x3_sum, that's because it is summing the variables in the order they are created.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Again be careful if you use this, as it could be confusing and easily broken if the code is changed.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 15:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MEAN-OF-X1-X12/m-p/751284#M236478</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-06-30T15:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: MEAN(OF  X1-X12)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MEAN-OF-X1-X12/m-p/751366#M236518</link>
      <description>&lt;P&gt;All of these difficulties are avoided if you have a long data set instead of a wide data set. Such as ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input id x;
    cards;
1 243
2 333
3 87
...
;
proc summary data=have;
    var x;
    output out=want sum=sum stddev=s;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and it's less typing. which means less chance for typographical errors or naming errors. and the code still works if you have a 13th data point (or a 14th data point or ...)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 22:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MEAN-OF-X1-X12/m-p/751366#M236518</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-30T22:16:18Z</dc:date>
    </item>
  </channel>
</rss>

