<?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 Conditional selection of rows from a multiple rows per observation data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditional-selection-of-rows-from-a-multiple-rows-per/m-p/789660#M252725</link>
    <description>&lt;P&gt;Dear Community,&lt;/P&gt;&lt;P&gt;I need your kind help regarding the following:&lt;/P&gt;&lt;P&gt;I wanted to select rows based on conditions from a multiple rows per observation dataset. See attached dataset in xls.&lt;/P&gt;&lt;P&gt;I wanted to select the row if 'otherDiagnosis' variables contains some specific values. There are 62 variables with prefix&amp;nbsp;&amp;nbsp;otherDiagnosis; i.e.&amp;nbsp;otherDiagnosis1,&amp;nbsp;otherDiagnosis2,&amp;nbsp;otherDiagnosis3,...otherDiagnosis62.&lt;/P&gt;&lt;P&gt;I&amp;nbsp;have written the following code, which serve my purpose nicely.&lt;/P&gt;&lt;P&gt;But I wanted to know if there is any other efficient way so that I don't have to repeat the lines 62 times in the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data B;
set A;
where otherDiagnosis1 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis2 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis3 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis4 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis5 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis6 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis7 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis8 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis9 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis10 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis11 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis12 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis13 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis14 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis15 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis16 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis17 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis18 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis19 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis20 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis21 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis22 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis23 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis24 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis25 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis26 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis27 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis28 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis29 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis30 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis31 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis32 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis33 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis34 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis35 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis36 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis37 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis38 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis39 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis40 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis41 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis42 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis43 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis44 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis45 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis46 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis47 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis48 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis49 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis50 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis51 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis52 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis53 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis54 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis55 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis56 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis57 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis58 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis59 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis60 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis61 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis62 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I appreciate your help in advanced.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sabbir&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jan 2022 09:25:25 GMT</pubDate>
    <dc:creator>strqimr1</dc:creator>
    <dc:date>2022-01-12T09:25:25Z</dc:date>
    <item>
      <title>Conditional selection of rows from a multiple rows per observation data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-selection-of-rows-from-a-multiple-rows-per/m-p/789660#M252725</link>
      <description>&lt;P&gt;Dear Community,&lt;/P&gt;&lt;P&gt;I need your kind help regarding the following:&lt;/P&gt;&lt;P&gt;I wanted to select rows based on conditions from a multiple rows per observation dataset. See attached dataset in xls.&lt;/P&gt;&lt;P&gt;I wanted to select the row if 'otherDiagnosis' variables contains some specific values. There are 62 variables with prefix&amp;nbsp;&amp;nbsp;otherDiagnosis; i.e.&amp;nbsp;otherDiagnosis1,&amp;nbsp;otherDiagnosis2,&amp;nbsp;otherDiagnosis3,...otherDiagnosis62.&lt;/P&gt;&lt;P&gt;I&amp;nbsp;have written the following code, which serve my purpose nicely.&lt;/P&gt;&lt;P&gt;But I wanted to know if there is any other efficient way so that I don't have to repeat the lines 62 times in the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data B;
set A;
where otherDiagnosis1 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis2 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis3 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis4 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis5 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis6 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis7 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis8 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis9 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis10 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis11 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis12 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis13 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis14 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis15 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis16 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis17 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis18 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis19 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis20 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis21 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis22 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis23 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis24 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis25 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis26 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis27 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis28 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis29 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis30 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis31 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis32 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis33 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis34 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis35 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis36 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis37 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis38 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis39 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis40 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis41 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis42 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis43 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis44 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis45 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis46 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis47 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis48 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis49 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis50 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis51 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis52 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis53 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis54 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis55 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis56 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis57 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis58 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis59 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis60 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis61 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
or otherDiagnosis62 in ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269")
; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I appreciate your help in advanced.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sabbir&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 09:25:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-selection-of-rows-from-a-multiple-rows-per/m-p/789660#M252725</guid>
      <dc:creator>strqimr1</dc:creator>
      <dc:date>2022-01-12T09:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional selection of rows from a multiple rows per observation data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-selection-of-rows-from-a-multiple-rows-per/m-p/789663#M252728</link>
      <description>&lt;P&gt;Use 2 arrays to accomplish this. &lt;BR /&gt;The first is for the values to check against. It resolves to true as row filter if any of the variables matches these values.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;my sas viya is down again (hopefully my company did better administrating sas viya) but the code (not tested) should be similar to this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data B;
set A;
array vary (*) otherDiagnosis1-otherDiagnosis62;
array check (8) $4. ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269");
stopy=0;
do i=1 to dim(check) until(stopy=1);
do j=1 to dim(vary);
if vary(j)=check(i) then stopy=1;
end;
end;
if stopy;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 09:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-selection-of-rows-from-a-multiple-rows-per/m-p/789663#M252728</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-01-12T09:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional selection of rows from a multiple rows per observation data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-selection-of-rows-from-a-multiple-rows-per/m-p/789673#M252740</link>
      <description>&lt;P&gt;Start by transposing the data to have only one Diagnosis variable (and multiple observations). Then a simple data step can solve the problem without using arrays and loops.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 10:41:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-selection-of-rows-from-a-multiple-rows-per/m-p/789673#M252740</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-01-12T10:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional selection of rows from a multiple rows per observation data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-selection-of-rows-from-a-multiple-rows-per/m-p/789689#M252745</link>
      <description>Using array as acordes did is a good idea.&lt;BR /&gt;&lt;BR /&gt;data B;&lt;BR /&gt;set A;&lt;BR /&gt;array vary (*) otherDiagnosis1-otherDiagnosis62;&lt;BR /&gt;array check (8) $4. ("H250", "H251", "H252", "H258", "H259", "H261", "H268", "H269");&lt;BR /&gt;&lt;BR /&gt;do j=1 to dim(vary);&lt;BR /&gt;if vary(j) in check then do;output; leave;end;&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;run;</description>
      <pubDate>Wed, 12 Jan 2022 12:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-selection-of-rows-from-a-multiple-rows-per/m-p/789689#M252745</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-12T12:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional selection of rows from a multiple rows per observation data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-selection-of-rows-from-a-multiple-rows-per/m-p/789867#M252815</link>
      <description>&lt;P&gt;Many thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127222"&gt;@acordes&lt;/a&gt;&amp;nbsp;for your help&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 01:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-selection-of-rows-from-a-multiple-rows-per/m-p/789867#M252815</guid>
      <dc:creator>strqimr1</dc:creator>
      <dc:date>2022-01-13T01:03:47Z</dc:date>
    </item>
  </channel>
</rss>

