<?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: Is it solved? variable names as values when you have multiple variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-it-solved-variable-names-as-values-when-you-have-multiple/m-p/404641#M98353</link>
    <description>&lt;P&gt;Sure, If you want to post sample data that I can work with.&lt;/P&gt;
&lt;P&gt;Otherwise, feel free to search for do loop examples on here. Or if you only care about two ones, then call WHICHN twice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can have, three, four, or five, how are you planning to deal with that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Oct 2017 00:00:35 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-10-17T00:00:35Z</dc:date>
    <item>
      <title>Is it solved? variable names as values when you have multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-solved-variable-names-as-values-when-you-have-multiple/m-p/404635#M98350</link>
      <description>I have 5 flags each having 1 and 0 (obviously). I have to write a code to get the column name when 1 is encountered. I came across a solution for using max or sum but I need to know if there is a solution when you come across two 1s, is there a way to get both the column names as the value? eg; A B C D E Column(obtained using vname) 1 0 0 0 0 A 0 1 1 0 0 B C 0 0 0 0 1 E 0 0 1 0 1 C E</description>
      <pubDate>Mon, 16 Oct 2017 23:53:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-solved-variable-names-as-values-when-you-have-multiple/m-p/404635#M98350</guid>
      <dc:creator>Ramakanthkrovi</dc:creator>
      <dc:date>2017-10-16T23:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: Is it solved? variable names as values when you have multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-solved-variable-names-as-values-when-you-have-multiple/m-p/404636#M98351</link>
      <description>&lt;P&gt;If you have more than one you'll need to use a loop.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151521"&gt;@Ramakanthkrovi&lt;/a&gt; wrote:&lt;BR /&gt;I have 5 flags each having 1 and 0 (obviously). I have to write a code to get the column name when 1 is encountered. I came across a solution for using max or sum but I need to know if there is a solution when you come across two 1s, is there a way to get both the column names as the value? eg; A B C D E Column(obtained using vname) 1 0 0 0 0 A 0 1 1 0 0 B C 0 0 0 0 1 E 0 0 1 0 1 C E&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 23:54:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-solved-variable-names-as-values-when-you-have-multiple/m-p/404636#M98351</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-16T23:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: Is it solved? variable names as values when you have multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-solved-variable-names-as-values-when-you-have-multiple/m-p/404639#M98352</link>
      <description>&lt;P&gt;array pat_(5) pat_:;&lt;BR /&gt;sum_value=sum(of pat_(*));&lt;BR /&gt;if sum_value = 1 then var_sum = vname(pat_(whichn(sum_value, of pat_(*))));&lt;BR /&gt;else&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Part of the code which I am using and it is a random fix which does not give me the values of two columns. Can you help me with the part of code to change please?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 23:59:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-solved-variable-names-as-values-when-you-have-multiple/m-p/404639#M98352</guid>
      <dc:creator>Ramakanthkrovi</dc:creator>
      <dc:date>2017-10-16T23:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Is it solved? variable names as values when you have multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-solved-variable-names-as-values-when-you-have-multiple/m-p/404641#M98353</link>
      <description>&lt;P&gt;Sure, If you want to post sample data that I can work with.&lt;/P&gt;
&lt;P&gt;Otherwise, feel free to search for do loop examples on here. Or if you only care about two ones, then call WHICHN twice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can have, three, four, or five, how are you planning to deal with that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2017 00:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-solved-variable-names-as-values-when-you-have-multiple/m-p/404641#M98353</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-17T00:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Is it solved? variable names as values when you have multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-solved-variable-names-as-values-when-you-have-multiple/m-p/404642#M98354</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2017 00:01:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-solved-variable-names-as-values-when-you-have-multiple/m-p/404642#M98354</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-17T00:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Is it solved? variable names as values when you have multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-solved-variable-names-as-values-when-you-have-multiple/m-p/404652#M98356</link>
      <description>&lt;P&gt;It looks like the variable names aren't necessarily A, B, C, D, and E anymore.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will need to decide whether you want a single variable to hold the flagged names (the approach I will use) vs. multiple variables.&amp;nbsp; here's one approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;length flagged_names $ 29;&lt;/P&gt;
&lt;P&gt;array flags {5} pat_1 - pat_5;&lt;/P&gt;
&lt;P&gt;do _n_=1 to 5;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if flags{_n_}=1 then flagged_names = catx(' ', flagged_names, vname(flags{_n_}) ) ;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Clearly if you have longer variable names, you may need to use a longer length for FLAGGED_NAMES.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2017 01:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-solved-variable-names-as-values-when-you-have-multiple/m-p/404652#M98356</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-17T01:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Is it solved? variable names as values when you have multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-solved-variable-names-as-values-when-you-have-multiple/m-p/404669#M98366</link>
      <description>Perfect!</description>
      <pubDate>Tue, 17 Oct 2017 04:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-solved-variable-names-as-values-when-you-have-multiple/m-p/404669#M98366</guid>
      <dc:creator>Ramakanthkrovi</dc:creator>
      <dc:date>2017-10-17T04:45:45Z</dc:date>
    </item>
  </channel>
</rss>

