<?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 SAS macro being weird in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-being-weird/m-p/622732#M183204</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've written the macro below to run 217 regressions by the variable "code", and save the estimates for each one in a different dataset, and then I want to save the value of the variable "code" itself" in the output dataset generated through the data statement. The problem is the "code" (which is 3 characters) is being included perfectly fine for all but 5 of the 217 datasets, and I can't figure out why. Any thoughts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro ln_gdp(code=);&lt;BR /&gt;proc glm data = two plots = none ;&lt;BR /&gt;model ln_gdp = year;&lt;BR /&gt;where code = "&amp;amp;code.";&lt;BR /&gt;ods output ParameterEstimates=PE_&amp;amp;code.;&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data PE_&amp;amp;code.; set PE_&amp;amp;code.;&lt;BR /&gt;code = "&amp;amp;code.";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend ln_gdp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;****Executing the macro*****;&lt;/P&gt;&lt;P&gt;*Get list of all codes;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table all_countries as&lt;BR /&gt;select distinct code&lt;BR /&gt;from two;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;*Run macro;&lt;BR /&gt;data _null_; *macro_call;&lt;BR /&gt;set all_countries;*&amp;nbsp;&lt;/P&gt;&lt;P&gt;*Build macro call string;&lt;BR /&gt;str = catt('%ln_gdp(code = ', code, ');');&lt;/P&gt;&lt;P&gt;*Call macro;&lt;BR /&gt;call execute(str);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Feb 2020 15:14:01 GMT</pubDate>
    <dc:creator>aowais</dc:creator>
    <dc:date>2020-02-06T15:14:01Z</dc:date>
    <item>
      <title>SAS macro being weird</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-being-weird/m-p/622732#M183204</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've written the macro below to run 217 regressions by the variable "code", and save the estimates for each one in a different dataset, and then I want to save the value of the variable "code" itself" in the output dataset generated through the data statement. The problem is the "code" (which is 3 characters) is being included perfectly fine for all but 5 of the 217 datasets, and I can't figure out why. Any thoughts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro ln_gdp(code=);&lt;BR /&gt;proc glm data = two plots = none ;&lt;BR /&gt;model ln_gdp = year;&lt;BR /&gt;where code = "&amp;amp;code.";&lt;BR /&gt;ods output ParameterEstimates=PE_&amp;amp;code.;&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data PE_&amp;amp;code.; set PE_&amp;amp;code.;&lt;BR /&gt;code = "&amp;amp;code.";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend ln_gdp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;****Executing the macro*****;&lt;/P&gt;&lt;P&gt;*Get list of all codes;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table all_countries as&lt;BR /&gt;select distinct code&lt;BR /&gt;from two;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;*Run macro;&lt;BR /&gt;data _null_; *macro_call;&lt;BR /&gt;set all_countries;*&amp;nbsp;&lt;/P&gt;&lt;P&gt;*Build macro call string;&lt;BR /&gt;str = catt('%ln_gdp(code = ', code, ');');&lt;/P&gt;&lt;P&gt;*Call macro;&lt;BR /&gt;call execute(str);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 15:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-being-weird/m-p/622732#M183204</guid>
      <dc:creator>aowais</dc:creator>
      <dc:date>2020-02-06T15:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro being weird</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-being-weird/m-p/622733#M183205</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/255712"&gt;@aowais&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The problem is the "code" (which is 3 characters) is being included perfectly fine for all but 5 of the 217 datasets, and I can't figure out why. Any thoughts?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What happens in those 5 datasets? Show us.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 15:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-being-weird/m-p/622733#M183205</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-06T15:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro being weird</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-being-weird/m-p/622735#M183206</link>
      <description>&lt;P&gt;It drops the last character: e.g. for code = RWA, it only saves RW, for code = SWE = it only saves SW&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 15:17:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-being-weird/m-p/622735#M183206</guid>
      <dc:creator>aowais</dc:creator>
      <dc:date>2020-02-06T15:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro being weird</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-being-weird/m-p/622744#M183209</link>
      <description>&lt;P&gt;Why don't you use BY CODE; instead of the WHERE and LOOP?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even if you insist on using WHERE/loop you can still use BY CODE: and you DON'T have to create it later.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 15:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-being-weird/m-p/622744#M183209</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2020-02-06T15:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro being weird</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-being-weird/m-p/622755#M183214</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/255712"&gt;@aowais&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It drops the last character: e.g. for code = RWA, it only saves RW, for code = SWE = it only saves SW&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since we don't have your data, we can't reproduce this or debug it. Please show us the code from the LOG (using &lt;FONT face="courier new,courier"&gt;options mprint;&lt;/FONT&gt;) and show us the resulting data set &lt;EM&gt;for one example where this happens&lt;/EM&gt;, or better yet, pay attention to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp;and follow his suggestion and get rid of the looping.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 16:07:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-being-weird/m-p/622755#M183214</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-06T16:07:25Z</dc:date>
    </item>
  </channel>
</rss>

