<?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 inside a macro? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/call-symput-inside-a-macro/m-p/140176#M261491</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In case it would help, here is a fairly standard way to combine a single observation data set with a multiple observation data set:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if _n_=1 then set testmean;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set original_data;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is possible that you would eliminate the macro language entirely.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 Jul 2014 12:57:50 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2014-07-29T12:57:50Z</dc:date>
    <item>
      <title>call symput inside a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput-inside-a-macro/m-p/140173#M261488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;_sym&lt;BR /&gt;&lt;SPAN style="font-family: book antiqua,palatino; font-size: 12pt;"&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: book antiqua,palatino; font-size: 12pt;"&gt;I am trying to nest call symput inside a simple macro.&amp;nbsp; I've tried something like this but can't get it to work:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;%macro mean_std (var);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;set testmean;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symputx ("&amp;amp;&amp;amp;var._Mean", &amp;amp;var._Mean);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;%put the mean of &amp;amp;var is &amp;amp;&amp;amp;var._Mean;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;%mend mean_std;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;%mean_std (CarePractice);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: book antiqua,palatino; font-size: 12pt;"&gt;Any ideas?&amp;nbsp; Thank you!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: book antiqua,palatino; font-size: 12pt;"&gt;Kelly&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jul 2014 12:23:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput-inside-a-macro/m-p/140173#M261488</guid>
      <dc:creator>kstolzmann</dc:creator>
      <dc:date>2014-07-29T12:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: call symput inside a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput-inside-a-macro/m-p/140174#M261489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you have additional ampersands (&amp;amp;):&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;%macro mean_std (var);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set testmean;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symputx("var_Mean", &amp;amp;var._Mean);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;%put the mean of &amp;amp;var is &amp;amp;var_Mean;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;%mend mean_std;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;%mean_std (CarePractice);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: comic sans ms,sans-serif; font-size: 12pt;"&gt;However I think you maybe unclear on the use of this.&amp;nbsp; I don't see an awfull lot of value in trying to unreference the variable to create a new variable like that.&amp;nbsp; If you are trying to create a new variable for the mean then:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%macro mean_std (var);&lt;BR /&gt;data want;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.cars (obs=1);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attrib &amp;amp;Var._mean format=best.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;var._mean=mean(&amp;amp;var.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput('result',&amp;amp;var._mean);&lt;BR /&gt;run;&lt;BR /&gt;%put the mean of &amp;amp;var is &amp;amp;result.;&lt;BR /&gt;%mend mean_std;&lt;/P&gt;&lt;P&gt;%mean_std (CarePractice);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe some test data and required output would help clarify.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jul 2014 12:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput-inside-a-macro/m-p/140174#M261489</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-07-29T12:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: call symput inside a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput-inside-a-macro/m-p/140175#M261490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, this works!&amp;nbsp; My CarePractice_Mean value is from an aggregated dataset so I want to use this value on my original data (in calculations).&amp;nbsp; I suppose I could have re-merged the aggregated dataset back to my original file (and I'm sure there are other more advanced ways of approaching this problem (using sql, etc.)).&amp;nbsp; Really, I was just trying to avoid typing in "36.7665" every time I needed to use the overall mean and it was bothering me that the code wasn't working (in case I really needed to use this type of call symput inside a macro in the future).&amp;nbsp; Thanks again for your help!&lt;/P&gt;&lt;P&gt;Kelly&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jul 2014 12:54:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput-inside-a-macro/m-p/140175#M261490</guid>
      <dc:creator>kstolzmann</dc:creator>
      <dc:date>2014-07-29T12:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: call symput inside a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput-inside-a-macro/m-p/140176#M261491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In case it would help, here is a fairly standard way to combine a single observation data set with a multiple observation data set:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if _n_=1 then set testmean;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set original_data;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is possible that you would eliminate the macro language entirely.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jul 2014 12:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput-inside-a-macro/m-p/140176#M261491</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-07-29T12:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: call symput inside a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput-inside-a-macro/m-p/140177#M261492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is helpful--thank you!&lt;/P&gt;&lt;P&gt;Kelly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jul 2014 13:34:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput-inside-a-macro/m-p/140177#M261492</guid>
      <dc:creator>kstolzmann</dc:creator>
      <dc:date>2014-07-29T13:34:10Z</dc:date>
    </item>
  </channel>
</rss>

