<?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 indirectly refer to a column header in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-indirectly-refer-to-a-column-header/m-p/293578#M61132</link>
    <description>&lt;P&gt;This should be a straightforward application of arrays:&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;array vars {3} v1 v2 v3;&lt;/P&gt;
&lt;P&gt;return = vars{lookup};&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that I illustrated using variable names of V1, V2, and V3, since 1, 2, and 3 are not valid variable names in SAS.&amp;nbsp; Also note that you may need to assign a length to RETURN before assigning a value.&amp;nbsp; If the variables in the array have different lengths, you may need to ensure that RETURN is assigned a long enough length to hold the longest value it might encounter.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Aug 2016 21:13:56 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-08-23T21:13:56Z</dc:date>
    <item>
      <title>How to indirectly refer to a column header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-indirectly-refer-to-a-column-header/m-p/293574#M61131</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I have a dataset where one column is filled with column headers, and I was to return the value from that header back to that row.&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS DAta Set:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name &amp;nbsp; Lookup &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp;&lt;STRONG&gt; Return&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;John &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a &amp;nbsp; &amp;nbsp; d &amp;nbsp; &amp;nbsp; &amp;nbsp;v &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;d&lt;/STRONG&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tim &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a &amp;nbsp; &amp;nbsp; c &amp;nbsp; &amp;nbsp; &amp;nbsp;v &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;&amp;nbsp;c&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Kat &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c &amp;nbsp; &amp;nbsp; d &amp;nbsp; &amp;nbsp; &amp;nbsp;v &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt; &amp;nbsp;v&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Jim &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c &amp;nbsp; &amp;nbsp; c &amp;nbsp; &amp;nbsp; &amp;nbsp;d &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;c&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;So as you can see from above&lt;/P&gt;&lt;P&gt;if lookup = 2 then return the value from column 2.&lt;/P&gt;&lt;P&gt;Now my dataset is much larger so I cant just use if/then to bring back every combination..&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 20:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-indirectly-refer-to-a-column-header/m-p/293574#M61131</guid>
      <dc:creator>timj22</dc:creator>
      <dc:date>2016-08-23T20:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to indirectly refer to a column header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-indirectly-refer-to-a-column-header/m-p/293578#M61132</link>
      <description>&lt;P&gt;This should be a straightforward application of arrays:&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;array vars {3} v1 v2 v3;&lt;/P&gt;
&lt;P&gt;return = vars{lookup};&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that I illustrated using variable names of V1, V2, and V3, since 1, 2, and 3 are not valid variable names in SAS.&amp;nbsp; Also note that you may need to assign a length to RETURN before assigning a value.&amp;nbsp; If the variables in the array have different lengths, you may need to ensure that RETURN is assigned a long enough length to hold the longest value it might encounter.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 21:13:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-indirectly-refer-to-a-column-header/m-p/293578#M61132</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-23T21:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to indirectly refer to a column header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-indirectly-refer-to-a-column-header/m-p/293585#M61136</link>
      <description>&lt;P&gt;Look at the VVALUE/VVALUEX function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 22:02:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-indirectly-refer-to-a-column-header/m-p/293585#M61136</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-23T22:02:56Z</dc:date>
    </item>
  </channel>
</rss>

