<?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: Extract value of nth column with various n in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-value-of-nth-column-with-various-n/m-p/333818#M75294</link>
    <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure if got this right, but the following might work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;
      set HAVE;
      keep ID VALUE;
      VALUE=VVALUEX(cats('VALUE',put(NUMBER,best.)));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;VVALUEX wil return the value of the variable which it's argument evaluates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm assuming NUMBER is a numeric variable, so PUT is just there to convert its numeric value into character representation.&lt;/P&gt;
&lt;P&gt;If not, then no need for the PUT function, just replace that with NUMBER.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope it helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Daniel Santos&amp;nbsp;@ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Feb 2017 15:54:08 GMT</pubDate>
    <dc:creator>DanielSantos</dc:creator>
    <dc:date>2017-02-17T15:54:08Z</dc:date>
    <item>
      <title>Extract value of nth column with various n</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-value-of-nth-column-with-various-n/m-p/333806#M75287</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a SAS table named A like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ID
NUMBER
VALUE1
VALUE2
...
VALUEn&lt;/PRE&gt;&lt;P&gt;I am sure that whatever the row, the value of the column "NUMBER" is a number between 1 and n.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use A to creaate a new table B which is like this&lt;/P&gt;&lt;PRE&gt;ID
VALUE&lt;/PRE&gt;&lt;P&gt;The management rule between A and B is the following:&lt;/P&gt;&lt;P&gt;For each of A row,&lt;/P&gt;&lt;P&gt;B.ID = A.ID&lt;/P&gt;&lt;P&gt;B.VALUE = A.VALUEi if A.NUMBER = i&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, if the column NUMBER from A is equal to 100, I need to get the value of the column VALUE100 and write it in&amp;nbsp;the column VALUE of table B.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I precise that VALUE1 ... VALUEn are fantasy names for explanation, the real names of column don't have indexes like this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any idea on how to do this in SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 15:32:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-value-of-nth-column-with-various-n/m-p/333806#M75287</guid>
      <dc:creator>fabdu92</dc:creator>
      <dc:date>2017-02-17T15:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value of nth column with various n</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-value-of-nth-column-with-various-n/m-p/333814#M75291</link>
      <description>&lt;P&gt;You mean u want to rotate the table and ignore the missing values of the value1,2,...n from table A and show only the columns which has values&amp;nbsp;&lt;/P&gt;&lt;P&gt;If that's the case then this might help u , I haven't tested,&lt;/P&gt;&lt;P&gt;data b(keep = id value);&lt;/P&gt;&lt;P&gt;Set a;&lt;/P&gt;&lt;P&gt;do I= 1 to n;&lt;/P&gt;&lt;P&gt;array value{i};&lt;/P&gt;&lt;P&gt;If value{i} ne . then&amp;nbsp;&lt;/P&gt;&lt;P&gt;Value=value{I};&lt;/P&gt;&lt;P&gt;End;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 15:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-value-of-nth-column-with-various-n/m-p/333814#M75291</guid>
      <dc:creator>gauthamk28</dc:creator>
      <dc:date>2017-02-17T15:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value of nth column with various n</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-value-of-nth-column-with-various-n/m-p/333815#M75292</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data b (keep=id value);
set a;
array vals{*} list of your variables;
value = vals{number};
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;All variables in the array must be of the same type.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 15:47:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-value-of-nth-column-with-various-n/m-p/333815#M75292</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-17T15:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value of nth column with various n</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-value-of-nth-column-with-various-n/m-p/333818#M75294</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure if got this right, but the following might work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;
      set HAVE;
      keep ID VALUE;
      VALUE=VVALUEX(cats('VALUE',put(NUMBER,best.)));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;VVALUEX wil return the value of the variable which it's argument evaluates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm assuming NUMBER is a numeric variable, so PUT is just there to convert its numeric value into character representation.&lt;/P&gt;
&lt;P&gt;If not, then no need for the PUT function, just replace that with NUMBER.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope it helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Daniel Santos&amp;nbsp;@ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 15:54:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-value-of-nth-column-with-various-n/m-p/333818#M75294</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2017-02-17T15:54:08Z</dc:date>
    </item>
  </channel>
</rss>

