<?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 output where a &amp;quot;Yes&amp;quot; exists in many rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-output-where-a-quot-Yes-quot-exists-in-many-rows/m-p/644302#M192440</link>
    <description>&lt;P&gt;If your flags were actual binary numeric variables you could use SUM() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=have;
where 1&amp;lt;sum(acl_recon,acl_repair,pcl_recon,pcl_repair,mcl_recon,mcl_repair 
           ,lcl_recon,cl_repair,plc_recon,plc_repair)
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With character variables you can use COUNT() and CATS().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where 1&amp;lt;count(cats(acl_recon,acl_repair,pcl_recon,pcl_repair,mcl_recon,mcl_repair 
                  ,lcl_recon,cl_repair,plc_recon,plc_repair)
             ,'Yes')
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 30 Apr 2020 16:30:19 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-04-30T16:30:19Z</dc:date>
    <item>
      <title>how to output where a "Yes" exists in many rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-output-where-a-quot-Yes-quot-exists-in-many-rows/m-p/644240#M192411</link>
      <description>&lt;P&gt;Using SAS 9.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following data:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;acl_recon&lt;/TD&gt;&lt;TD&gt;acl_repair&lt;/TD&gt;&lt;TD&gt;pcl_recon&lt;/TD&gt;&lt;TD&gt;pcl_repair&lt;/TD&gt;&lt;TD&gt;mcl_recon&lt;/TD&gt;&lt;TD&gt;mcl_repair&lt;/TD&gt;&lt;TD&gt;lcl_recon&lt;/TD&gt;&lt;TD&gt;lcl_repair&lt;/TD&gt;&lt;TD&gt;plc_recon&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;plc_repair&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All of the above are binary (Yes/No) variables and none have missing data. Is there an efficient way to code looking for where a "Yes" occurs within these variables and outputting where multiple "Yes" occur? Meaning, If "acl_recon" and "lcl_recon" and "mcl_repair" and "plc_recon" are all = 'Yes' the output variable (I would like all of the data to go into 1 variable) should read "ACL recon/LCL recon/MCL repair/PLC recon". It is possible there could only be 1 variable with a "Yes" or there could be 9 variables with a "Yes". Any thoughts would be helpful. Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to do this without having to write lots of if/then statements? Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 13:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-output-where-a-quot-Yes-quot-exists-in-many-rows/m-p/644240#M192411</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-04-30T13:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to output where a "Yes" exists in many rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-output-where-a-quot-Yes-quot-exists-in-many-rows/m-p/644242#M192412</link>
      <description>&lt;P&gt;If I understand you correctly, do this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (acl_recon acl_repair pcl_recon pcl_repair mcl_recon mcl_repair lcl_recon lcl_repair plc_recon plc_repair)(:$);
datalines;
Yes No Yes Yes No Yes No Yes Yes Yes
Yes No Yes No No Yes No Yes Yes Yes
Yes No No Yes No Yes No No Yes Yes
;

data want(drop=i);
    set have;
    length newvar $ 200;
    array a _character_;
    do i = 1 to dim(a);
        if a[i] = 'Yes' then do;
            newvar = catx('/', newvar, vname(a[i]));
        end;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Apr 2020 13:34:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-output-where-a-quot-Yes-quot-exists-in-many-rows/m-p/644242#M192412</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-04-30T13:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to output where a "Yes" exists in many rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-output-where-a-quot-Yes-quot-exists-in-many-rows/m-p/644248#M192414</link>
      <description>Thank you! That worked perfectly</description>
      <pubDate>Thu, 30 Apr 2020 14:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-output-where-a-quot-Yes-quot-exists-in-many-rows/m-p/644248#M192414</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-04-30T14:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to output where a "Yes" exists in many rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-output-where-a-quot-Yes-quot-exists-in-many-rows/m-p/644250#M192415</link>
      <description>&lt;P&gt;Anytime &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 14:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-output-where-a-quot-Yes-quot-exists-in-many-rows/m-p/644250#M192415</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-04-30T14:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to output where a "Yes" exists in many rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-output-where-a-quot-Yes-quot-exists-in-many-rows/m-p/644256#M192419</link>
      <description>&lt;P&gt;Just for giggles, what is that variable with variable names to be used for?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And with what tools?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 14:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-output-where-a-quot-Yes-quot-exists-in-many-rows/m-p/644256#M192419</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-30T14:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to output where a "Yes" exists in many rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-output-where-a-quot-Yes-quot-exists-in-many-rows/m-p/644272#M192427</link>
      <description>&lt;P&gt;It is being used for a descriptive gut check basically&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 15:10:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-output-where-a-quot-Yes-quot-exists-in-many-rows/m-p/644272#M192427</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-04-30T15:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to output where a "Yes" exists in many rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-output-where-a-quot-Yes-quot-exists-in-many-rows/m-p/644302#M192440</link>
      <description>&lt;P&gt;If your flags were actual binary numeric variables you could use SUM() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=have;
where 1&amp;lt;sum(acl_recon,acl_repair,pcl_recon,pcl_repair,mcl_recon,mcl_repair 
           ,lcl_recon,cl_repair,plc_recon,plc_repair)
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With character variables you can use COUNT() and CATS().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where 1&amp;lt;count(cats(acl_recon,acl_repair,pcl_recon,pcl_repair,mcl_recon,mcl_repair 
                  ,lcl_recon,cl_repair,plc_recon,plc_repair)
             ,'Yes')
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Apr 2020 16:30:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-output-where-a-quot-Yes-quot-exists-in-many-rows/m-p/644302#M192440</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-30T16:30:19Z</dc:date>
    </item>
  </channel>
</rss>

