<?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 sum  excluding a specific value within a row in arrays in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-excluding-a-specific-value-within-a-row-in-arrays/m-p/674269#M203012</link>
    <description>&lt;P&gt;The problem could be solved by using a trivial where-statement in proc summary, but since you don't want to change the format of the data, that path is locked.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Aug 2020 05:06:34 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2020-08-04T05:06:34Z</dc:date>
    <item>
      <title>How to sum  excluding a specific value within a row in arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-excluding-a-specific-value-within-a-row-in-arrays/m-p/674173#M202963</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset as below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data scores;&lt;/P&gt;
&lt;P&gt;input m1 m2 m3 m4 m5 m6;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;8 4 3 8 8 6&lt;/P&gt;
&lt;P&gt;4 8 2 1 3 1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;8 8 2&amp;nbsp; 2 8 8&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to get sum of values which are not equal to 8, i.e for ex&amp;nbsp; for&amp;nbsp; first row I need only sum of 4+3+6 .Is there anyway I can do this by arrays&amp;nbsp; and I need to keep the values as they are .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 03 Aug 2020 16:59:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-excluding-a-specific-value-within-a-row-in-arrays/m-p/674173#M202963</guid>
      <dc:creator>sri1</dc:creator>
      <dc:date>2020-08-03T16:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum  excluding a specific value within a row in arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-excluding-a-specific-value-within-a-row-in-arrays/m-p/674177#M202966</link>
      <description>&lt;P&gt;Is 8 supposed to be a generic code for "this is not really a value" such as a response to a question with something like "I don't know" or "I don't want to answer this question"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, you might be better off recoding the variable to a special missing value so you don't have to keep excluding the value from specific operations.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Aug 2020 17:07:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-excluding-a-specific-value-within-a-row-in-arrays/m-p/674177#M202966</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-03T17:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum  excluding a specific value within a row in arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-excluding-a-specific-value-within-a-row-in-arrays/m-p/674185#M202971</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/80196"&gt;@sri1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to get sum of values which are not equal to 8, i.e for ex&amp;nbsp; for&amp;nbsp; first row I need only sum of 4+3+6 .Is there anyway I can do this by arrays&amp;nbsp; and I need to keep the values as they are .&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data scores;
input m1 m2 m3 m4 m5 m6;
array m(*) m1-m6;
sum=0;
do i=1 to dim(m);
    if m(i)^=8 then sum=sum+m(i);
end;
drop i;
datalines;
8 4 3 8 8 6
4 8 2 1 3 1 
8 8 2  2 8 8
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Aug 2020 17:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-excluding-a-specific-value-within-a-row-in-arrays/m-p/674185#M202971</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-03T17:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum  excluding a specific value within a row in arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-excluding-a-specific-value-within-a-row-in-arrays/m-p/674269#M203012</link>
      <description>&lt;P&gt;The problem could be solved by using a trivial where-statement in proc summary, but since you don't want to change the format of the data, that path is locked.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 05:06:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-excluding-a-specific-value-within-a-row-in-arrays/m-p/674269#M203012</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-08-04T05:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum  excluding a specific value within a row in arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-excluding-a-specific-value-within-a-row-in-arrays/m-p/674275#M203014</link>
      <description>&lt;P&gt;With a proper data structure, PROC SUMMARY does this quite easily:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=long (where=(m ne 8));
by id;
var m;
output out=sum (keep=id sum_m) sum(m)=sum_m;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To achieve this, you need to transpose, and you can merge back if needed:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data scores;
input m1 m2 m3 m4 m5 m6;
id = _n_;
datalines;
8 4 3 8 8 6
4 8 2 1 3 1 
8 8 2  2 8 8
;

proc transpose
  data=scores
  out=long (keep=id instance col1 rename=(col1=m))
  name=instance
;
by id;
var m:;
run;

proc summary data=long (where=(m ne 8));
by id;
var m;
output out=sum (keep=id sum_m) sum(m)=sum_m;
run;

data want;
merge
  scores
  sum
;
by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Aug 2020 06:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-excluding-a-specific-value-within-a-row-in-arrays/m-p/674275#M203014</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-04T06:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum  excluding a specific value within a row in arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-excluding-a-specific-value-within-a-row-in-arrays/m-p/674297#M203024</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;I need to keep the values as they are .&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yes, I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;. People often state restrictions on the data or restrictions on what SAS solutions are acceptable without good reason, and this just makes their life harder. Even if you have to keep the values as they are, a transpose leaves the original data set intact and provides and easier solution to obtaining the desired sum. A better restriction, in my mind, is to find the easiest programming path.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 10:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-excluding-a-specific-value-within-a-row-in-arrays/m-p/674297#M203024</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-04T10:36:55Z</dc:date>
    </item>
  </channel>
</rss>

