<?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 Table cell indicating which column's value to use in equation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Table-cell-indicating-which-column-s-value-to-use-in-equation/m-p/84196#M18146</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am looking for a straightforward / easy way to do the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Say I have the table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data INPUT_DATASET;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input a $1. b c;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;b 10 20&lt;/P&gt;&lt;P&gt;c 30 40&lt;/P&gt;&lt;P&gt;b 50 60&lt;/P&gt;&lt;P&gt;c 70 80&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first variable (i.e. a) is the name of the column/variables of which I want to use the value in an equation.&amp;nbsp; Say my equation is 10*X, where X is either the value of b or c, depending on what column a says it should be.&amp;nbsp; (I don't want to use IF statements, for I work from the assumption that I don't know the variables that column a can refer to.&amp;nbsp; I need it more dynamic than that.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I have tried, which obviously did not work but would illustrate what I want, is the following:&lt;/P&gt;&lt;P&gt;data TEST_OUTPUT; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set INPUT_DATASET;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('%let current_var = ' || a );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TEST=10*&amp;amp;current_var;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;The warning is:&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference CURRENT_VAR not resolved&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, my question is: is there an easy straightforward way to do what I want to do, or should I work around it (such as first determining the unknown variables (b and c in this case) and then using a macro with a loop over the determined list of variables)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Pieter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Jan 2013 05:22:10 GMT</pubDate>
    <dc:creator>PHK</dc:creator>
    <dc:date>2013-01-24T05:22:10Z</dc:date>
    <item>
      <title>Table cell indicating which column's value to use in equation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-cell-indicating-which-column-s-value-to-use-in-equation/m-p/84196#M18146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am looking for a straightforward / easy way to do the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Say I have the table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data INPUT_DATASET;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input a $1. b c;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;b 10 20&lt;/P&gt;&lt;P&gt;c 30 40&lt;/P&gt;&lt;P&gt;b 50 60&lt;/P&gt;&lt;P&gt;c 70 80&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first variable (i.e. a) is the name of the column/variables of which I want to use the value in an equation.&amp;nbsp; Say my equation is 10*X, where X is either the value of b or c, depending on what column a says it should be.&amp;nbsp; (I don't want to use IF statements, for I work from the assumption that I don't know the variables that column a can refer to.&amp;nbsp; I need it more dynamic than that.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I have tried, which obviously did not work but would illustrate what I want, is the following:&lt;/P&gt;&lt;P&gt;data TEST_OUTPUT; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set INPUT_DATASET;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('%let current_var = ' || a );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TEST=10*&amp;amp;current_var;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;The warning is:&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference CURRENT_VAR not resolved&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, my question is: is there an easy straightforward way to do what I want to do, or should I work around it (such as first determining the unknown variables (b and c in this case) and then using a macro with a loop over the determined list of variables)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Pieter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 05:22:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-cell-indicating-which-column-s-value-to-use-in-equation/m-p/84196#M18146</guid>
      <dc:creator>PHK</dc:creator>
      <dc:date>2013-01-24T05:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Table cell indicating which column's value to use in equation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-cell-indicating-which-column-s-value-to-use-in-equation/m-p/84197#M18147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A colleague of mine suggested using the VNAME function, so I do have a solution now:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data TEST;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set INPUT_DATASET;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array numeric_vars{*} _NUMERIC_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i = 1 to dim(numeric_vars);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if vname(numeric_vars{i}) = a then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TEMP_VALUE = numeric_vars{i};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; leave;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; TEST = TEMP_VALUE*10;&lt;/P&gt;&lt;P&gt;&amp;nbsp; drop i TEMP_VALUE;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there perhaps an even more straight forward way than looping through the variables?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 07:42:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-cell-indicating-which-column-s-value-to-use-in-equation/m-p/84197#M18147</guid>
      <dc:creator>PHK</dc:creator>
      <dc:date>2013-01-24T07:42:31Z</dc:date>
    </item>
  </channel>
</rss>

