<?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: String To Variable Name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207446#M38572</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Although we were wondering if there was a function approach to left side assigment, if not, arrays (or PROC TRANSPOSE) is a good approach for us.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Jul 2015 17:11:42 GMT</pubDate>
    <dc:creator>blert</dc:creator>
    <dc:date>2015-07-21T17:11:42Z</dc:date>
    <item>
      <title>String To Variable Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207439#M38565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;Hi all,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;There is a question that maybe someone could help us with.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;Is it possible to &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif; background: white;"&gt;convert a string to a SAS variable name at datastep execution time? We mean, for example, during execution of datastep being able of doing something like this:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR2=str_to_varname("VAR1"); /* using the value of existing VAR1 variable to define other variable*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 13.3333330154419px;"&gt;str_to_varname("VAR1")=4; /*definition of VAR1 variable*/&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if &lt;SPAN style="font-size: 13.3333330154419px;"&gt;str_to_varname("VAR1")=5 then VAR3=7; /* using values of existing VAR1 variable in logical expressions*/&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;It is to say, to dynamically at execution time and without using macro language or arrays, being able to treat a string as a datastep variable name.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;Thank you,&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 15:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207439#M38565</guid>
      <dc:creator>blert</dc:creator>
      <dc:date>2015-07-21T15:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: String To Variable Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207440#M38566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think you can do it directly as part of the datastep execution, as that part is not dynamic.&amp;nbsp; Macro, call execute, are your best bet, these generate the code before going onto the datastep compilation.&amp;nbsp; What are you trying to do, there may be other ways of getting what you want.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 15:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207440#M38566</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-07-21T15:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: String To Variable Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207441#M38567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you try using VVALUEX() function?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002233818.htm"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002233818.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 15:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207441#M38567</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-07-21T15:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: String To Variable Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207442#M38568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002233818.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002233818.htm"&gt;SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VVALUEX()&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: arial, 'Arial Unicode MS', geneva, 'Lucida Grande', sans-serif; font-size: 13.4399995803833px; font-weight: bold; background-color: #ffffff;"&gt;Returns the formatted value that is associated with the variable that you specify.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 15:38:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207442#M38568</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-07-21T15:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: String To Variable Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207443#M38569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot all of you. We had not considered the EXECUTE way. &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Nice to hear from VVALUEX() function. It is what we were looking for. The only thing to mention would be that it would not allow left side assigments like: &lt;SPAN style="font-family: Arial, sans-serif; font-size: 13.3333330154419px; background-color: #ffffff;"&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;VVALUEX&lt;/SPAN&gt;("VAR1")=VAR2;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again for your responses, VVALUEX() will be very useful for us.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 16:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207443#M38569</guid>
      <dc:creator>blert</dc:creator>
      <dc:date>2015-07-21T16:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: String To Variable Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207444#M38570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Left side assignments are what arrays are for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array out var1 var2 var3 ;&lt;/P&gt;&lt;P&gt;target='VAR2';&lt;/P&gt;&lt;P&gt;do i=1 to dim(out);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if target = vname(out(i)) then out(i)=1 ;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 16:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207444#M38570</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-07-21T16:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: String To Variable Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207445#M38571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you explain the problem there is probably another way to do what you want that does not need dynamically referenced variables.&lt;/P&gt;&lt;P&gt;For example if you have source data in NAME, VALUE pairs then you can use PROC TRANSPOSE to convert the data into variable using the value of NAME as the name of the variable and VALUE as the value for the variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 16:43:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207445#M38571</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-07-21T16:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: String To Variable Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207446#M38572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Although we were wondering if there was a function approach to left side assigment, if not, arrays (or PROC TRANSPOSE) is a good approach for us.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2015 17:11:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/String-To-Variable-Name/m-p/207446#M38572</guid>
      <dc:creator>blert</dc:creator>
      <dc:date>2015-07-21T17:11:42Z</dc:date>
    </item>
  </channel>
</rss>

