<?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 dynamically update SAS Variables based on pre-defined key, Variable name info? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/545132#M150772</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/204379"&gt;@ez123&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Agree, using symputx() won't work here as the macro variable will only become available after the data step (timing issue).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eventually one could get around this via dosubl() but I believe that still wouldn't resolve the issue. Basically: The variable assignment code needs to exist during the compilation phase. There is no way to generate such syntax during execution time of the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below code should do what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data config;
  length source $1 updt_Field $12;
  input source $ updt_Field $;
  datalines;
A field1
B field2
;
run;

data fmtds;
  set config;
  rename source=start updt_field=label;
  retain fmtname '$CodeToVname';
run;
proc format cntlin=fmtds;
run;

/* option 1 */
data fmtds(drop=_:);
  length field1 $20 field2 $20 value $10;
  array _cvars {*} _character_;
  fmtname='VnameToArrElement'; type='I';
  do _i=1 to dim(_cvars);
    start=vname(_cvars[_i]);
    label=_i;
    output;
  end;
  stop;
run;
proc format cntlin=fmtds;
run;
data out;
  length field1 $20 field2 $20 value $10;
  array _cvars {*} _character_;
  source='A';
  value='0000099999';
  _cvars[input(put(source,$CodeToVname.),VnameToArrElement.)]=value;
run;

/* option 2 */
data out(drop=_i);
  length field1 $20 field2 $20 value $10;
  array _cvars {*} _character_;
  source='A';
  value='0000099999';
  do _i=1 to dim(_cvars);
    if vname(_cvars[_i])=put(source,$CodeToVname.) then
      do;
        _cvars[_i]=value;
        leave;
      end;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is some sort of request/response scenario where you only create a single row per table "OUT" then I'd go for Option 2 and I'd also consider to create a permanent format from the Config table (updated via a housekeeping job).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you've got "many" rows in table 'OUT" to process then I'd go for Option 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might also want to add some "upcasing" to the code I've posted so that codes and variable names match if casing in sources differs.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Mar 2019 06:30:12 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-03-22T06:30:12Z</dc:date>
    <item>
      <title>How to dynamically update SAS Variables based on pre-defined key, Variable name info?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544960#M150722</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I have config file that contains the following info:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;source &lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Field name to be updated &lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The user might provide me with a specific source information and value to be updated. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I need to read the config file and find out the Field name to be updated and update the corresponding field with the user input value.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Below is my code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; config;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; length source $&lt;STRONG&gt;1&lt;/STRONG&gt; updt_Field $&lt;STRONG&gt;12&lt;/STRONG&gt; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input source $ updt_Field $;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;A field1&lt;/P&gt;&lt;P&gt;B field2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; out;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; length field1 $&lt;STRONG&gt;20&lt;/STRONG&gt; field2 $&lt;STRONG&gt;20&lt;/STRONG&gt; value $&lt;STRONG&gt;10&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if &lt;STRONG&gt;0&lt;/STRONG&gt; then set config;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _N_ = &lt;STRONG&gt;1&lt;/STRONG&gt; then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* load config data set into the hash object */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare hash h_src(dataset: 'work.config');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* define SMALL data set variable K as key and S as value */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h_src.defineKey('source');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h_src.defineData('updt_Field');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h_src.defineDone();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* avoid uninitialized variable notes */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call missing(source,updt_Field);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value='0000099999';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop rc;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; source='2';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc = h_src.find();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put updt_Field;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * I want to update the field represented in the updt_Field variable with the value;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vnamex(updt_Field)=value;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 17:33:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544960#M150722</guid>
      <dc:creator>ez123</dc:creator>
      <dc:date>2019-03-21T17:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically update SAS Variables based on pre-defined key, Variable name info?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544967#M150724</link>
      <description>&lt;P&gt;Does the code do as you expect or what results differ from your expected results? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 18:00:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544967#M150724</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-03-21T18:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically update SAS Variables based on pre-defined key, Variable name info?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544969#M150726</link>
      <description>&lt;P&gt;It errors out at the vnamex function. I was kind of hoping the vnamex function would do the job for me but its not the case!!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 18:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544969#M150726</guid>
      <dc:creator>ez123</dc:creator>
      <dc:date>2019-03-21T18:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically update SAS Variables based on pre-defined key, Variable name info?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544973#M150728</link>
      <description>&lt;P&gt;Ok. Just to be clear. The&amp;nbsp;&lt;SPAN&gt;source='2'; statemet, does that indicate that it is the second variable that has to be updated with the given value?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 18:08:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544973#M150728</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-03-21T18:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically update SAS Variables based on pre-defined key, Variable name info?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544976#M150729</link>
      <description>&lt;P&gt;Actually the statement should be &lt;FONT face="Courier New" size="3"&gt;source=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'A'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; which indicates that&amp;nbsp;field1 should be updated with the value "&lt;/FONT&gt;0000099999".&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 18:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544976#M150729</guid>
      <dc:creator>ez123</dc:creator>
      <dc:date>2019-03-21T18:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically update SAS Variables based on pre-defined key, Variable name info?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544984#M150732</link>
      <description>&lt;P&gt;How will you know which value to use? Will it always be the '0000099999' as a character?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 18:40:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544984#M150732</guid>
      <dc:creator>noling</dc:creator>
      <dc:date>2019-03-21T18:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically update SAS Variables based on pre-defined key, Variable name info?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544986#M150734</link>
      <description>&lt;P&gt;For now, we can assume the value would be always constant. but again, I can always read this as input from a user.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 18:47:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544986#M150734</guid>
      <dc:creator>ez123</dc:creator>
      <dc:date>2019-03-21T18:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically update SAS Variables based on pre-defined key, Variable name info?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544990#M150735</link>
      <description>&lt;P&gt;I'm &lt;EM&gt;intrigued&amp;nbsp;&lt;/EM&gt;using a hash in a datastep to do this.&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;do you know if it's possible to use the vnamex function on the left-hand side of an expression?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 18:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/544990#M150735</guid>
      <dc:creator>noling</dc:creator>
      <dc:date>2019-03-21T18:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically update SAS Variables based on pre-defined key, Variable name info?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/545018#M150740</link>
      <description>&lt;P&gt;There are several ways to work around this issue. Here is one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data config;
   length source $1 updt_Field $12 ;
   input source $ updt_Field $;
   datalines;
A field1
B field2
;
run;

data out;
     length field1 $20 field2 $20 value $10;
     if 0 then set config;
     if _N_ = 1 then do;
     /* load config data set into the hash object */
     declare hash h_src(dataset: 'work.config');
     /* define SMALL data set variable K as key and S as value */
     h_src.defineKey('source');
     h_src.defineData('updt_Field');
     h_src.defineDone();
     /* avoid uninitialized variable notes */
     call missing(source,updt_Field);
     end;

     value='0000099999';
     drop rc;

     source='A';
     rc = h_src.find();

     call symputx('updt_Field', updt_Field);
     &amp;amp;updt_Field.=value;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Mar 2019 20:17:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/545018#M150740</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-03-21T20:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically update SAS Variables based on pre-defined key, Variable name info?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/545088#M150760</link>
      <description>symputx doesn't work as coded above. have tried this method before and am getting the same error!</description>
      <pubDate>Thu, 21 Mar 2019 22:44:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/545088#M150760</guid>
      <dc:creator>ez123</dc:creator>
      <dc:date>2019-03-21T22:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically update SAS Variables based on pre-defined key, Variable name info?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/545132#M150772</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/204379"&gt;@ez123&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Agree, using symputx() won't work here as the macro variable will only become available after the data step (timing issue).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eventually one could get around this via dosubl() but I believe that still wouldn't resolve the issue. Basically: The variable assignment code needs to exist during the compilation phase. There is no way to generate such syntax during execution time of the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below code should do what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data config;
  length source $1 updt_Field $12;
  input source $ updt_Field $;
  datalines;
A field1
B field2
;
run;

data fmtds;
  set config;
  rename source=start updt_field=label;
  retain fmtname '$CodeToVname';
run;
proc format cntlin=fmtds;
run;

/* option 1 */
data fmtds(drop=_:);
  length field1 $20 field2 $20 value $10;
  array _cvars {*} _character_;
  fmtname='VnameToArrElement'; type='I';
  do _i=1 to dim(_cvars);
    start=vname(_cvars[_i]);
    label=_i;
    output;
  end;
  stop;
run;
proc format cntlin=fmtds;
run;
data out;
  length field1 $20 field2 $20 value $10;
  array _cvars {*} _character_;
  source='A';
  value='0000099999';
  _cvars[input(put(source,$CodeToVname.),VnameToArrElement.)]=value;
run;

/* option 2 */
data out(drop=_i);
  length field1 $20 field2 $20 value $10;
  array _cvars {*} _character_;
  source='A';
  value='0000099999';
  do _i=1 to dim(_cvars);
    if vname(_cvars[_i])=put(source,$CodeToVname.) then
      do;
        _cvars[_i]=value;
        leave;
      end;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is some sort of request/response scenario where you only create a single row per table "OUT" then I'd go for Option 2 and I'd also consider to create a permanent format from the Config table (updated via a housekeeping job).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you've got "many" rows in table 'OUT" to process then I'd go for Option 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might also want to add some "upcasing" to the code I've posted so that codes and variable names match if casing in sources differs.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 06:30:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/545132#M150772</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-03-22T06:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically update SAS Variables based on pre-defined key, Variable name info?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/545133#M150773</link>
      <description>&lt;P&gt;As a last resort, you could always split the DATA step in two.&amp;nbsp; Instead of VNAMEX, capture the variable name as a macro variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call symputx('varname', Updt_field);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then use a new DATA step to utilize &amp;amp;VARNAME.&amp;nbsp; However, before resorting to that, let's explore some other lookup methods other than a hash table.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems that the user chooses the value to be updated.&amp;nbsp; Presumably, that can be captured as a macro variable, equivalent to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let user_choice=A;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at the CONFIG file, the UPDT_FIELD values must be legal SAS variable names.&amp;nbsp; Is the same true for the values of SOURCE?&amp;nbsp; Are they always a single letter (or a set of letters that could be a valid SAS variable name)?&amp;nbsp; If so, the problem lends itself to a different approach.&amp;nbsp; First, convert the CONFIG file to a set of macro variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; length source $&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;updt_Field $&lt;STRONG&gt;12&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; input source $ updt_Field $;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;call symputx(source, updt_field);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;
&lt;P&gt;A field1&lt;/P&gt;
&lt;P&gt;B field2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having done that, the look-up is simple:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data out;&lt;/P&gt;
&lt;P&gt;&amp;amp;&amp;amp;&amp;amp;user_choice = '0000099999';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only downside to this approach is that you lose error-handling ability if the user enters a bad value (if the CONFIG file defines "A" and "B", and the user enters "C" instead).&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 06:22:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/545133#M150773</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-03-22T06:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically update SAS Variables based on pre-defined key, Variable name info?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/545388#M150862</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115150"&gt;@noling&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm &lt;EM&gt;intrigued&amp;nbsp;&lt;/EM&gt;using a hash in a datastep to do this.&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;do you know if it's possible to use the vnamex function on the left-hand side of an expression?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pretty sure that use of VNAMEX(anything) = causes an&lt;/P&gt;
&lt;P&gt;ERROR: Undeclared array referenced: vnamex.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As will VNAME and all the variable information functions except for the CALL functions. They&amp;nbsp;return&amp;nbsp;some sort of value&amp;nbsp;given a variable name, array reference&amp;nbsp;or for the correct functions, an expression that resolves to a name and can assign that resolved value to another variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 22:07:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-update-SAS-Variables-based-on-pre-defined-key/m-p/545388#M150862</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-22T22:07:32Z</dc:date>
    </item>
  </channel>
</rss>

