<?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: Subset data based on the contents of group dummy variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478257#M123327</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Sorry for a confusion, I will correct that. Below is the error I got.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Array subscript out of range at line 377 column 15.&lt;/P&gt;
&lt;P&gt;374&amp;nbsp; data p.wrong_1 p.wrong_0;&lt;BR /&gt;375&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set p.have;&lt;BR /&gt;376&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array m z1-z7;&lt;BR /&gt;377&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if sum(of m)&amp;gt;1 then output p.wrong_1;&lt;BR /&gt;378&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else output p.wrong_0;&lt;BR /&gt;379&amp;nbsp; run;&lt;BR /&gt;&lt;BR /&gt;ERROR: Array subscript out of range at line 377 column 15.&lt;BR /&gt;id=a z1=0 z2=0 z3=0 z4=0 z5=0 z6=1 z7=1 _I_=. _ERROR_=1 _N_=1&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: There were 1 observations read from the data set P.HAVE.&lt;BR /&gt;WARNING: The data set P.WRONG_1 may be incomplete.&amp;nbsp; When this step was stopped there were 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; observations and 8 variables.&lt;BR /&gt;WARNING: Data set P.WRONG_1 was not replaced because this step was stopped.&lt;BR /&gt;WARNING: The data set P.WRONG_0 may be incomplete.&amp;nbsp; When this step was stopped there were 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; observations and 8 variables.&lt;BR /&gt;WARNING: Data set P.WRONG_0 was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.42 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;/P&gt;</description>
    <pubDate>Mon, 16 Jul 2018 02:08:39 GMT</pubDate>
    <dc:creator>Cruise</dc:creator>
    <dc:date>2018-07-16T02:08:39Z</dc:date>
    <item>
      <title>Subset data based on the contents of group dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478243#M123313</link>
      <description>&lt;P&gt;I'm trying to separate the data 'have' to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output_1 if any dummy variable in z1-z7 series contains '1'&lt;/P&gt;
&lt;P&gt;else&lt;/P&gt;
&lt;P&gt;output_0 if&amp;nbsp; z1-z7 series are all '0'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as shown below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, my current code using array results are wrong as you can see from wrong_0 and wrong_1 resulting datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any hints? what am I doing wrong here? I placed 'end' before and after output with no success. Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id $ z1 z2 z3 z4 z5 z6 z7;
cards;
a 0 0 0 0 0 1 1
b 0 0 0 0 0 0 0
c 1 0 0 0 0 0 0
d 0 1 1 0 0 0 0
e 0 0 0 0 0 0 1
f 0 0 0 0 0 0 0
; 

data output_0;
input id $ z1 z2 z3 z4 z5 z6 z7;
cards;
b 0 0 0 0 0 0 0
f 0 0 0 0 0 0 0
;

data output_1;
input id $ z1 z2 z3 z4 z5 z6 z7;
cards;
a 0 0 0 0 0 1 1
c 1 0 0 0 0 0 0
d 0 1 1 0 0 0 0
e 0 0 0 0 0 0 1
;

data wrong_1; set have; /*output data has N=6 rows instead 4*/
array m z:; 
 do over m;
if m in ('1') then output; 
end; 
run;

data wrong_0; set have; /*output data has N=36 rows instead 2*/
array m z:; 
 do over m;
if m in ('0') then output; 
end; 
run;


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 15:07:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478243#M123313</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-07-16T15:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: Subset data based on the contents of group dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478244#M123314</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id $ z1 z2 z3 z4 z5 z6 z7;
cards;
a 0 0 0 0 0 1 1
b 0 0 0 0 0 0 0
c 1 0 0 0 0 0 0
d 0 1 1 0 0 0 0
e 0 0 0 0 0 0 1
f 0 0 0 0 0 0 0
; 

data output_0  output_1;
set have;
if max(of z1-z7)&amp;gt;0 then output output_0;
else output output_1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Jul 2018 22:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478244#M123314</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-07-15T22:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Subset data based on the contents of group dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478245#M123315</link>
      <description>&lt;P&gt;using var list z:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data output_0  output_1;
set have;
if max(of z:)&amp;gt;0 then output output_0;
else output output_1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Jul 2018 22:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478245#M123315</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-07-15T22:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Subset data based on the contents of group dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478246#M123316</link>
      <description>&lt;P&gt;Well this is certainly confusing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;output_0 if any dummy variable in z1-z7 series contains '1'&lt;/P&gt;
&lt;P&gt;else&lt;/P&gt;
&lt;P&gt;output_1 if&amp;nbsp; z1-z7 series are all '0'&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;because your code does the exact opposite.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, this should get the data separated properly, except for the confusion stated above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data wrong_1 wrong_0;
    set have;
    if sum(of z:)&amp;gt;1 then output wrong_1;
    else output wrong_0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Sun, 15 Jul 2018 22:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478246#M123316</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-15T22:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Subset data based on the contents of group dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478257#M123327</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Sorry for a confusion, I will correct that. Below is the error I got.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Array subscript out of range at line 377 column 15.&lt;/P&gt;
&lt;P&gt;374&amp;nbsp; data p.wrong_1 p.wrong_0;&lt;BR /&gt;375&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set p.have;&lt;BR /&gt;376&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array m z1-z7;&lt;BR /&gt;377&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if sum(of m)&amp;gt;1 then output p.wrong_1;&lt;BR /&gt;378&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else output p.wrong_0;&lt;BR /&gt;379&amp;nbsp; run;&lt;BR /&gt;&lt;BR /&gt;ERROR: Array subscript out of range at line 377 column 15.&lt;BR /&gt;id=a z1=0 z2=0 z3=0 z4=0 z5=0 z6=1 z7=1 _I_=. _ERROR_=1 _N_=1&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: There were 1 observations read from the data set P.HAVE.&lt;BR /&gt;WARNING: The data set P.WRONG_1 may be incomplete.&amp;nbsp; When this step was stopped there were 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; observations and 8 variables.&lt;BR /&gt;WARNING: Data set P.WRONG_1 was not replaced because this step was stopped.&lt;BR /&gt;WARNING: The data set P.WRONG_0 may be incomplete.&amp;nbsp; When this step was stopped there were 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; observations and 8 variables.&lt;BR /&gt;WARNING: Data set P.WRONG_0 was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.42 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 02:08:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478257#M123327</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-07-16T02:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: Subset data based on the contents of group dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478258#M123328</link>
      <description>&lt;P&gt;if you are using array, your syntax is the issue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if sum(of m)&amp;gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;should be&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if sum(of m(*))&amp;gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and if you are using &lt;STRONG&gt;in&lt;/STRONG&gt; operator&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data wrong_1 wrong_0;&lt;BR /&gt;set have;&lt;BR /&gt;array m z1-z7;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;if 1 in m then output wrong_1;&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;else output wrong_0;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 02:34:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478258#M123328</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-07-16T02:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Subset data based on the contents of group dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478325#M123361</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;ERROR: Array subscript out of range at line 377 column 15.&lt;/P&gt;
&lt;P&gt;374&amp;nbsp; data p.wrong_1 p.wrong_0;&lt;BR /&gt;375&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set p.have;&lt;BR /&gt;376&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array m z1-z7;&lt;BR /&gt;377&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if sum(of m)&amp;gt;1 then output p.wrong_1;&lt;BR /&gt;378&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else output p.wrong_0;&lt;BR /&gt;379&amp;nbsp; run;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I showed simpler code that you have changed, causing the error. Run my exact code without changes.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 11:04:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478325#M123361</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-16T11:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: Subset data based on the contents of group dummy variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478390#M123377</link>
      <description>I edited the question. Thanks for pointing out.</description>
      <pubDate>Mon, 16 Jul 2018 15:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-data-based-on-the-contents-of-group-dummy-variables/m-p/478390#M123377</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-07-16T15:08:20Z</dc:date>
    </item>
  </channel>
</rss>

