<?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: Call symput within a local macro? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Call-symput-within-a-local-macro/m-p/164304#M31770</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi pmesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your current code defines the new macro variables as local macro variables. To use them outside of the macro, just declare them as global macro variables. Changing your code as shown below fixes the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro abcd(data=,mvar=);&lt;/P&gt;&lt;P&gt;data a2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set &amp;amp;data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %global &amp;amp;mvar;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call symput("&amp;amp;mvar",xyz);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%abcd (data=a0, mvar=mvar0);&lt;/P&gt;&lt;P&gt;%abcd (data=a1, mvar=mvar1);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Dec 2014 18:02:06 GMT</pubDate>
    <dc:creator>StatsGeek</dc:creator>
    <dc:date>2014-12-29T18:02:06Z</dc:date>
    <item>
      <title>Call symput within a local macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-symput-within-a-local-macro/m-p/164301#M31767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following is the typical call symput procedure:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a2;&lt;/P&gt;&lt;P&gt;set a1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call symput("mvar",xyz);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to do the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro abcd (data=,mvar=);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a2;&lt;/P&gt;&lt;P&gt;set &amp;amp;data;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call symput("&amp;amp;mvar",xyz)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%abcd (data=a0, mvar=mvar0)&lt;/P&gt;&lt;P&gt;%abcd (data=a1, mvar=mvar1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I'm getting error. Can I assign macro variable name within call symput through a local macro? Is there any efficient way to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Dec 2014 16:53:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-symput-within-a-local-macro/m-p/164301#M31767</guid>
      <dc:creator>pmesh</dc:creator>
      <dc:date>2014-12-29T16:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Call symput within a local macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-symput-within-a-local-macro/m-p/164302#M31768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a untested code, please try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro abcd (data=,mvar=);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a2;&lt;/P&gt;&lt;P&gt;set &amp;amp;data;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call symput("mvar"||strip(&amp;amp;mvar),xyz)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%abcd (data=a0, mvar=0);&lt;/P&gt;&lt;P&gt;%abcd (data=a1, mvar=1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Dec 2014 17:07:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-symput-within-a-local-macro/m-p/164302#M31768</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2014-12-29T17:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: Call symput within a local macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-symput-within-a-local-macro/m-p/164303#M31769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jag,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your prompt reply. Unfortunately, it is not working and I'm getting an error saying that the symbolic variable name mvar. must contain only letters, digits, and underscores.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any possibility of renaming the macro variable created by call symput?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Dec 2014 17:30:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-symput-within-a-local-macro/m-p/164303#M31769</guid>
      <dc:creator>pmesh</dc:creator>
      <dc:date>2014-12-29T17:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Call symput within a local macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-symput-within-a-local-macro/m-p/164304#M31770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi pmesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your current code defines the new macro variables as local macro variables. To use them outside of the macro, just declare them as global macro variables. Changing your code as shown below fixes the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro abcd(data=,mvar=);&lt;/P&gt;&lt;P&gt;data a2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set &amp;amp;data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %global &amp;amp;mvar;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call symput("&amp;amp;mvar",xyz);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%abcd (data=a0, mvar=mvar0);&lt;/P&gt;&lt;P&gt;%abcd (data=a1, mvar=mvar1);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Dec 2014 18:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-symput-within-a-local-macro/m-p/164304#M31770</guid>
      <dc:creator>StatsGeek</dc:creator>
      <dc:date>2014-12-29T18:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Call symput within a local macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-symput-within-a-local-macro/m-p/164305#M31771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot Stephen! That worked perfectly!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Dec 2014 19:05:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-symput-within-a-local-macro/m-p/164305#M31771</guid>
      <dc:creator>pmesh</dc:creator>
      <dc:date>2014-12-29T19:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: Call symput within a local macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-symput-within-a-local-macro/m-p/164306#M31772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or use the third parameter 'G'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro abcd(data=,mvar=);&lt;/P&gt;&lt;P&gt;data a2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set &amp;amp;data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call symputx("&amp;amp;mvar",age,&lt;STRONG&gt;'G'&lt;/STRONG&gt;);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%abcd (data=sashelp.class, mvar=mvar0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put _global_ ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Dec 2014 06:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-symput-within-a-local-macro/m-p/164306#M31772</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-12-30T06:29:16Z</dc:date>
    </item>
  </channel>
</rss>

