<?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: Trying to Count &amp;amp; Produce Multiple Names from Variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591896#M169656</link>
    <description>Paige Miller,&lt;BR /&gt;&lt;BR /&gt;Awesome! Thank you. Do you have any thoughts on how to return those antidepressant names where there are multiple? I am trying to get a true measure of the distribution of them.&lt;BR /&gt;&lt;BR /&gt;Thank you</description>
    <pubDate>Thu, 26 Sep 2019 15:31:12 GMT</pubDate>
    <dc:creator>dellerrrr</dc:creator>
    <dc:date>2019-09-26T15:31:12Z</dc:date>
    <item>
      <title>Trying to Count &amp; Produce Multiple Names from Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591882#M169649</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I am struggling with a problem I cannot seem to resolve. I am trying to see the frequency that different antidepressants are appearing in the dataset along with if there are observations with more than one antidepressant. Every observation will have SubstanceName1-SubstanceName30 and Class1-Class30. Below is some sample data of how it appears in the set.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample Data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID#&amp;nbsp; &amp;nbsp; &amp;nbsp; SubstanceName1&amp;nbsp; &amp;nbsp; &amp;nbsp; SubstanceClass1&amp;nbsp; &amp;nbsp; &amp;nbsp;SubstanceName2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SubstanceClass2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Trazodone&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Antidepressant&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Fluoxetine&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Antidepressant&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Heroin&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Opiate&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Trazodone&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Antidepressant&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently the array code I am using below will only return the name of an antidepressant that appears last if there are multiple. Is there any way to count if there are observations with multiple antidepressants like the ID#1, and if so to return both Substance Names? Thank you for any guidance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Data depress;&lt;BR /&gt;set set_1;&lt;/P&gt;&lt;P&gt;Array AntiD $ SubstanceClass1-SubstanceClass30;&lt;BR /&gt;Array Name $ SubstanceName1-SubstanceName30;&lt;BR /&gt;do i= 1 to 30;&lt;BR /&gt;if AntiD(i) = 'Antidepressant' then Depression = Name(i);&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 15:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591882#M169649</guid>
      <dc:creator>dellerrrr</dc:creator>
      <dc:date>2019-09-26T15:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to Count &amp; Produce Multiple Names from Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591884#M169650</link>
      <description>&lt;P&gt;It seems like this will work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data depress;
    set set_1;
    Array AntiD $ SubstanceClass1-SubstanceClass30;
    Array Name $ SubstanceName1-SubstanceName30;
    count=0;
    do i= 1 to 30;
        if AntiD(i) = 'Antidepressant' then Depression = Name(i);
        count=count+1;
        output;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Sep 2019 15:18:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591884#M169650</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-26T15:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to Count &amp; Produce Multiple Names from Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591889#M169653</link>
      <description>PaigeMiller,&lt;BR /&gt;&lt;BR /&gt;Unfortunately this has Depression return as blank,&lt;BR /&gt;&amp;amp; count has simply counted from 1 to 30 down the data and then resets at the 31st observation</description>
      <pubDate>Thu, 26 Sep 2019 15:23:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591889#M169653</guid>
      <dc:creator>dellerrrr</dc:creator>
      <dc:date>2019-09-26T15:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to Count &amp; Produce Multiple Names from Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591892#M169654</link>
      <description>&lt;P&gt;My mistake, how about this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data depress;
    set set_1;
    Array AntiD $ SubstanceClass1-SubstanceClass30;
    Array Name $ SubstanceName1-SubstanceName30;
    count=0;
    do i= 1 to 30;
        if AntiD(i) = 'Antidepressant' then do;
            Depression = Name(i);
            count=count+1;
            output;
        end;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Sep 2019 15:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591892#M169654</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-26T15:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to Count &amp; Produce Multiple Names from Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591896#M169656</link>
      <description>Paige Miller,&lt;BR /&gt;&lt;BR /&gt;Awesome! Thank you. Do you have any thoughts on how to return those antidepressant names where there are multiple? I am trying to get a true measure of the distribution of them.&lt;BR /&gt;&lt;BR /&gt;Thank you</description>
      <pubDate>Thu, 26 Sep 2019 15:31:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591896#M169656</guid>
      <dc:creator>dellerrrr</dc:creator>
      <dc:date>2019-09-26T15:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to Count &amp; Produce Multiple Names from Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591921#M169661</link>
      <description>Can you restructure your data? If it's in a long form, this is much easier to answer these types of questions.</description>
      <pubDate>Thu, 26 Sep 2019 16:39:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591921#M169661</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-09-26T16:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to Count &amp; Produce Multiple Names from Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591923#M169662</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/284404"&gt;@dellerrrr&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Paige Miller,&lt;BR /&gt;&lt;BR /&gt;Awesome! Thank you. Do you have any thoughts on how to return those antidepressant names where there are multiple? I am trying to get a true measure of the distribution of them.&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't know what this means. Show me the exact output you want.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 16:42:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591923#M169662</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-26T16:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to Count &amp; Produce Multiple Names from Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591939#M169665</link>
      <description>I was looking to return the substance names total. So if there is only one match just one name, and if more than return multiple. I tranposed the data like Reeza suggested and have figured it out.&lt;BR /&gt;&lt;BR /&gt;Thank you!</description>
      <pubDate>Thu, 26 Sep 2019 17:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591939#M169665</guid>
      <dc:creator>dellerrrr</dc:creator>
      <dc:date>2019-09-26T17:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to Count &amp; Produce Multiple Names from Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591957#M169676</link>
      <description>If you're in a long format, SQL will do 'aggregations' on character variables and/or count distinct which can make life a lot easier to figure out the number of distinct drugs a client is using.</description>
      <pubDate>Thu, 26 Sep 2019 18:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-Count-amp-Produce-Multiple-Names-from-Variables/m-p/591957#M169676</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-09-26T18:44:17Z</dc:date>
    </item>
  </channel>
</rss>

