<?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 use value of one variable to reference another variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/use-value-of-one-variable-to-reference-another-variable/m-p/479632#M123842</link>
    <description>&lt;P&gt;I am trying to use the value of one variable to reference another variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input one two three value$;&lt;BR /&gt;cards;&lt;BR /&gt;1 2 3 two&lt;BR /&gt;1 2 3 .&lt;BR /&gt;1 2 3 one&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;input one two three;&lt;BR /&gt;cards;&lt;BR /&gt;1 . 3&lt;BR /&gt;1 2 3&lt;BR /&gt;. 2 3&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In row one the variable value = 'two', so I want the variable two to = null.&amp;nbsp; In row value is null so there is no action.&amp;nbsp; In row three value = 'one' so the variable one is changed to null.&amp;nbsp; If anyone can help do this I'd appreciate it.&amp;nbsp; I'm trying to use vvaluex() to do this but not getting there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;</description>
    <pubDate>Thu, 19 Jul 2018 18:24:34 GMT</pubDate>
    <dc:creator>Steelers_In_DC</dc:creator>
    <dc:date>2018-07-19T18:24:34Z</dc:date>
    <item>
      <title>use value of one variable to reference another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-value-of-one-variable-to-reference-another-variable/m-p/479632#M123842</link>
      <description>&lt;P&gt;I am trying to use the value of one variable to reference another variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input one two three value$;&lt;BR /&gt;cards;&lt;BR /&gt;1 2 3 two&lt;BR /&gt;1 2 3 .&lt;BR /&gt;1 2 3 one&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;input one two three;&lt;BR /&gt;cards;&lt;BR /&gt;1 . 3&lt;BR /&gt;1 2 3&lt;BR /&gt;. 2 3&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In row one the variable value = 'two', so I want the variable two to = null.&amp;nbsp; In row value is null so there is no action.&amp;nbsp; In row three value = 'one' so the variable one is changed to null.&amp;nbsp; If anyone can help do this I'd appreciate it.&amp;nbsp; I'm trying to use vvaluex() to do this but not getting there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 18:24:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-value-of-one-variable-to-reference-another-variable/m-p/479632#M123842</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2018-07-19T18:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: use value of one variable to reference another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-value-of-one-variable-to-reference-another-variable/m-p/479638#M123845</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input one two three value$;
cards;
1 2 3 two
1 2 3 .
1 2 3 one
;
run;

data want;
set have;
array t(*) one--three;
do _n_=1 to dim(t);
if vname(t(_n_))=value then call missing(t(_n_));
end;
drop value;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jul 2018 18:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-value-of-one-variable-to-reference-another-variable/m-p/479638#M123845</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-07-19T18:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: use value of one variable to reference another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-value-of-one-variable-to-reference-another-variable/m-p/479754#M123870</link>
      <description>&lt;P&gt;You may want to check case of your variable name and the value&amp;nbsp;as variable names can be stored in mixed case.&lt;/P&gt;
&lt;PRE&gt;data have;
input One two three value $;
cards;
1 2 3 two
1 2 3 .
1 2 3 one
;
run;

data want;
  set have;
  array a one two three;
  do i = 1 to dim(a);
   if vname(a[i]) = value then a[i]=.;
  end;
  drop i value;
run;&lt;/PRE&gt;
&lt;P&gt;Does not set the missing value on the third row because the case comparison doesn't match. Better might be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;   if upcase( vname(a[i]) ) = upcase( value) then a[i]=.;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jul 2018 23:10:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-value-of-one-variable-to-reference-another-variable/m-p/479754#M123870</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-19T23:10:36Z</dc:date>
    </item>
  </channel>
</rss>

