<?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: Assign value of column name based on hierachy of column names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assign-value-of-column-name-based-on-hierachy-of-column-names/m-p/431940#M106895</link>
    <description>&lt;P&gt;Z2 format will add 0 in front and it's not an issue with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new=catt('Var', put(index, z2.));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 29 Jan 2018 20:00:48 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-01-29T20:00:48Z</dc:date>
    <item>
      <title>Assign value of column name based on hierachy of column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-value-of-column-name-based-on-hierachy-of-column-names/m-p/431921#M106885</link>
      <description>&lt;P&gt;Hi I have a table with a series of variables that have 1 or ' '&amp;nbsp; as values.&amp;nbsp; The variable are named as var1, var2, ..., var16.&amp;nbsp; If we just use var1-3 as example here, I want to create a new variable 'new'&amp;nbsp;that has value of the variable name that has 1, but if&amp;nbsp;a row has&amp;nbsp;2 or more variables&amp;nbsp;with 1, then pick the&amp;nbsp;smaller variable number, for example&amp;nbsp;like this table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Var1 Var2 Var3&amp;nbsp; new&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var3&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var1&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 19:31:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-value-of-column-name-based-on-hierachy-of-column-names/m-p/431921#M106885</guid>
      <dc:creator>sunless07652</dc:creator>
      <dc:date>2018-01-29T19:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Assign value of column name based on hierachy of column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-value-of-column-name-based-on-hierachy-of-column-names/m-p/431924#M106886</link>
      <description>&lt;P&gt;Are your variable names var1, var2, var3 etc?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, look at the WHICHC/N functions which return the first index of the value you're looking for, assuming numeric it would look something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;index = whichn(1, of var1-var16);
new=catt('Var', index);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jan 2018 19:41:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-value-of-column-name-based-on-hierachy-of-column-names/m-p/431924#M106886</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-29T19:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Assign value of column name based on hierachy of column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-value-of-column-name-based-on-hierachy-of-column-names/m-p/431925#M106887</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Var1 Var2 Var3  ;
datalines;
1 . 1
. . 1
1 1 1  
. 1 1
;

data want;
set have;
array t(*) var:;
k=whichn(1, of t[*]);
new=vname(t(k));
drop k;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jan 2018 19:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-value-of-column-name-based-on-hierachy-of-column-names/m-p/431925#M106887</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-29T19:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Assign value of column name based on hierachy of column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-value-of-column-name-based-on-hierachy-of-column-names/m-p/431938#M106893</link>
      <description>&lt;P&gt;This is great.&amp;nbsp; Actually the variable are named TAPQ01-TAPQ16, so there's the 0 in front of 1-9, but I can just create a new set of variables named TAPQ1-TAPQ16, or just list them one by one.&amp;nbsp; Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 19:59:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-value-of-column-name-based-on-hierachy-of-column-names/m-p/431938#M106893</guid>
      <dc:creator>sunless07652</dc:creator>
      <dc:date>2018-01-29T19:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: Assign value of column name based on hierachy of column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-value-of-column-name-based-on-hierachy-of-column-names/m-p/431939#M106894</link>
      <description>&lt;P&gt;This is perfect, thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 20:00:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-value-of-column-name-based-on-hierachy-of-column-names/m-p/431939#M106894</guid>
      <dc:creator>sunless07652</dc:creator>
      <dc:date>2018-01-29T20:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: Assign value of column name based on hierachy of column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-value-of-column-name-based-on-hierachy-of-column-names/m-p/431940#M106895</link>
      <description>&lt;P&gt;Z2 format will add 0 in front and it's not an issue with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new=catt('Var', put(index, z2.));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jan 2018 20:00:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-value-of-column-name-based-on-hierachy-of-column-names/m-p/431940#M106895</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-29T20:00:48Z</dc:date>
    </item>
  </channel>
</rss>

