<?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 Value from Coloumn Name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Value-from-Coloumn-Name/m-p/12746#M1415</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I have a dataset(name : new) which has 4 coloumns(c1 , c2 , c3 ,c4).&lt;BR /&gt;
c4 coloumn consists the name of the coloumns ( c2,c1,.......).&lt;BR /&gt;
please see example below:&lt;BR /&gt;
&lt;BR /&gt;
Dataset: New &lt;BR /&gt;
c1 c2 c3 c4&lt;BR /&gt;
1  2   3    c2&lt;BR /&gt;
1  3   5    c1&lt;BR /&gt;
&lt;BR /&gt;
I did as follow:&lt;BR /&gt;
data a;&lt;BR /&gt;
set new;&lt;BR /&gt;
t1 = max(0,c1 - c4);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Here I want C4 to be replaced with the value. Meaning in the first row , the value for c4 is c2 so I want value of c2(Value of C2  : 2) to be substituted and so on...&lt;BR /&gt;
&lt;BR /&gt;
Please help me .&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
    <pubDate>Tue, 14 Jun 2011 11:26:14 GMT</pubDate>
    <dc:creator>SASACC</dc:creator>
    <dc:date>2011-06-14T11:26:14Z</dc:date>
    <item>
      <title>Value from Coloumn Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Value-from-Coloumn-Name/m-p/12746#M1415</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I have a dataset(name : new) which has 4 coloumns(c1 , c2 , c3 ,c4).&lt;BR /&gt;
c4 coloumn consists the name of the coloumns ( c2,c1,.......).&lt;BR /&gt;
please see example below:&lt;BR /&gt;
&lt;BR /&gt;
Dataset: New &lt;BR /&gt;
c1 c2 c3 c4&lt;BR /&gt;
1  2   3    c2&lt;BR /&gt;
1  3   5    c1&lt;BR /&gt;
&lt;BR /&gt;
I did as follow:&lt;BR /&gt;
data a;&lt;BR /&gt;
set new;&lt;BR /&gt;
t1 = max(0,c1 - c4);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Here I want C4 to be replaced with the value. Meaning in the first row , the value for c4 is c2 so I want value of c2(Value of C2  : 2) to be substituted and so on...&lt;BR /&gt;
&lt;BR /&gt;
Please help me .&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Tue, 14 Jun 2011 11:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Value-from-Coloumn-Name/m-p/12746#M1415</guid>
      <dc:creator>SASACC</dc:creator>
      <dc:date>2011-06-14T11:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Value from Coloumn Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Value-from-Coloumn-Name/m-p/12747#M1416</link>
      <description>Have a look at the VVALUE / VVALUEX function.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
return value of variable site:sas.com

Message was edited by: sbb</description>
      <pubDate>Tue, 14 Jun 2011 11:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Value-from-Coloumn-Name/m-p/12747#M1416</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-06-14T11:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Value from Coloumn Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Value-from-Coloumn-Name/m-p/12748#M1417</link>
      <description>Hello SASAcc,&lt;BR /&gt;
&lt;BR /&gt;
I am not sure that understand you correctly. What do you mean by t1 = max(0,c1 - c4);? &lt;BR /&gt;
&lt;BR /&gt;
Is this t1 = max(0,c1,c2,c3);&lt;BR /&gt;
or t1 = max(0,c1-c3):?&lt;BR /&gt;
&lt;BR /&gt;
Using c4 is impossible because c1, c2, c3 are numeric and c4 is character.&lt;BR /&gt;
&lt;BR /&gt;
Anyway this my solution:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Data New;&lt;BR /&gt;
  input c1 c2 c3 c4 $;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 2 3 c2&lt;BR /&gt;
1 3 5 c1&lt;BR /&gt;
run;&lt;BR /&gt;
data a;&lt;BR /&gt;
  set new;&lt;BR /&gt;
  t1 = max(0, c1,c2,c3);&lt;BR /&gt;
  if      c4="c2" then c2=t1;&lt;BR /&gt;
  else if c4="c1" then c1=t1;&lt;BR /&gt;
  drop t1;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre] &lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Wed, 15 Jun 2011 20:50:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Value-from-Coloumn-Name/m-p/12748#M1417</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-06-15T20:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: Value from Coloumn Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Value-from-Coloumn-Name/m-p/12749#M1418</link>
      <description>please explain why C4 is to be considered for the MAX() &lt;BR /&gt;
The value it holds seems to be a pointer to one of the other C(n) columns - so including the value to which C4 points will not introduce anything larger than MAX( of C1-C3 )</description>
      <pubDate>Thu, 16 Jun 2011 13:37:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Value-from-Coloumn-Name/m-p/12749#M1418</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-06-16T13:37:44Z</dc:date>
    </item>
  </channel>
</rss>

