<?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: Issues with macro vars resolving when used in proc X12 specs in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343493#M63390</link>
    <description>&lt;P&gt;Along with what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;has asked, what does &lt;EM&gt;reg&lt;/EM&gt; contain? Does it potentially contain parentheses?&lt;/P&gt;</description>
    <pubDate>Wed, 22 Mar 2017 20:13:31 GMT</pubDate>
    <dc:creator>LaurieF</dc:creator>
    <dc:date>2017-03-22T20:13:31Z</dc:date>
    <item>
      <title>Issues with macro vars resolving when used in proc X12 specs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343462#M63385</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set containing X12 specs for about 150 series. I am trying to build a macro do loop that will assign new values to macro variables for the X12 specs as the do loop goes through the series. I keep having issues with how the macro variables used in the X12 speca are resolving.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the record I have tried:&lt;/P&gt;&lt;P&gt;= "&amp;amp;reg";&lt;/P&gt;&lt;P&gt;= (&amp;amp;reg);&lt;/P&gt;&lt;P&gt;=("&amp;amp;reg");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro doauto;
%do i=1 %to &amp;amp;numauto;

data am;
set qspecauto;
if ct = &amp;amp;i;
call symput ('reg',strip(reg_predefined));
call symput ('acctt', strip(acctt));
run;

data qnsause;
set qnsa;
if strip(acctt)= "&amp;amp;acctt"; /* This resolves fine*/
run;

proc x12 data = QNSAuse date = period interval = qtr outstat = X12Sum;
var NSA;
id;
regression predefined = &amp;amp;reg;/*&amp;lt;----- This has issues*/
automdl;
run;

%end;
%mend doauto;

%doauto;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The error in the log is:&lt;/P&gt;&lt;P&gt;MPRINT(DOAUTO): proc x12 data = QNSAuse date = period interval = qtr outstat = X12Sum;&lt;BR /&gt;MPRINT(DOAUTO): var NSA;&lt;BR /&gt;MPRINT(DOAUTO): id;&lt;BR /&gt;SYMBOLGEN: Macro variable REG resolves to td easter&lt;BR /&gt;NOTE: Line generated by the invoked macro "DOAUTO".&lt;BR /&gt;2 var NSA; id; regression predefined = &amp;amp;reg; automdl; run;&lt;BR /&gt;-&lt;BR /&gt;79&lt;BR /&gt;ERROR 79-322: Expecting a (.&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the invoked macro "DOAUTO".&lt;BR /&gt;2 var NSA; id; regression predefined = &amp;amp;reg; automdl; run;&lt;BR /&gt;-&lt;BR /&gt;76&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;MPRINT(DOAUTO): regression predefined = td easter;&lt;BR /&gt;MPRINT(DOAUTO): automdl;&lt;BR /&gt;MPRINT(DOAUTO): run;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 18:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343462#M63385</guid>
      <dc:creator>alicek</dc:creator>
      <dc:date>2017-03-22T18:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with macro vars resolving when used in proc X12 specs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343492#M63389</link>
      <description>&lt;P&gt;What does your X12 code look like without macro code and the variables hard coded in? Does that work without errors?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 20:09:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343492#M63389</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-22T20:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with macro vars resolving when used in proc X12 specs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343493#M63390</link>
      <description>&lt;P&gt;Along with what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;has asked, what does &lt;EM&gt;reg&lt;/EM&gt; contain? Does it potentially contain parentheses?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 20:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343493#M63390</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-03-22T20:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with macro vars resolving when used in proc X12 specs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343504#M63394</link>
      <description>&lt;P&gt;I tried this after I posted and was just coming back to update my question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ran just the proc x12 with hardcoded &amp;amp;reg ( td easter ) I did get the same error. Ultimately I'm using someone elses old X12 specs to run seasonal adjustment this year. So, instead of using automdl I decided to just specify the arima model that was the final model used&amp;nbsp;last year. The code works this way even in the macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't say why because I don't know enough about X12 but maybe there's an issue with supplying a regression spec if you select automdl or there's an issue with the order in which I specified. Whaterv the issue, I've found a solution that works for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for both of your quick replies!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Alice&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 20:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343504#M63394</guid>
      <dc:creator>alicek</dc:creator>
      <dc:date>2017-03-22T20:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with macro vars resolving when used in proc X12 specs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343532#M63397</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Issues with macro vars resolving when used in proc X12 specs

seems to work ok for me

inspired by
https://goo.gl/BCUnos
https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343462

HAVE
====

Up to 40 obs WORK.HAVE1 total obs=19

Obs    CT    REG_PREDEFINED

  1     1       Alfred
  2     2       Alice
  3     3       Barbara
  4     4       Carol
  5     5       Henry
  6     6       James


Up to 40 obs from have2 total obs=57

Obs    NSA    ACCTT      SALES

  1     14    Alfred      69.0   Model these
  2      2    Alfred      57.0
  3     39    Alfred      61.0

  4     13    Alice       56.5   Model these
  5     70    Alice       92.0
  6     81    Alice       12.0

  7     13    Barbara     65.3  Model these
  8     36    Barbara     49.0
  9     51    Barbara     30.0


WANT (Three datasets WORK.ALICE WORK.ALFRED WORK.BARBARA
========================================================
ALICE

Up to 40 obs from ALICE total obs=1

Obs    _MODEL_    _DEPVAR_    INTERCEPT      SALES

 1      Alice       NSA        65.1136     -0.19527

ALFRED

Up to 40 obs from ALFRED total obs=1

Obs    _MODEL_    _DEPVAR_    INTERCEPT     SALES

 1     Alfred       NSA        -7.26786    0.41071

BARBARA

Up to 40 obs from BARBARA total obs=1

Obs    _MODEL_    _DEPVAR_    INTERCEPT      SALES

 1     Barbara      NSA        84.7342     -1.06863

WORKING CODE
============

   do i=1 to 3;
     dosubl
        set have1;
        if ct=&amp;amp;ct;
        call symputx ("reg",reg_predefined);
        call symputx ("acctt", reg_predefined);
        set have2;
        if acctt= "&amp;amp;acctt";
        proc reg data=qnsause outest = &amp;amp;reg;
        &amp;amp;reg: model nsa=sales  ;
        run;quit;

FULL SOLUTION
=============
*                _                  _       _
 _ __ ___   __ _| | _____        __| | __ _| |_ __ _
| '_ ` _ \ / _` | |/ / _ \_____ / _` |/ _` | __/ _` |
| | | | | | (_| |   &amp;lt;  __/_____| (_| | (_| | || (_| |
|_| |_| |_|\__,_|_|\_\___|      \__,_|\__,_|\__\__,_|

;


proc datasets lib=work kill;
run;quit;

data have1;
  retain ct 0;
  length ct 8 reg_predefined $8;
  set sashelp.class(keep=name rename=name=reg_predefined);
  ct=_n_;
run;quit;

data have2;
  length nsa 8 acctt $8;
  set sashelp.class(keep=name age height
       rename=(age=nsa name=acctt height=sales));
  output;
  nsa=int(100*uniform(5731));sales=int(100*uniform(5732));output;
  nsa=int(100*uniform(5733));sales=int(100*uniform(5734));output;
run;quit;

*          _       _   _
 ___  ___ | |_   _| |_(_) ___  _ __
/ __|/ _ \| | | | | __| |/ _ \| '_ \
\__ \ (_) | | |_| | |_| | (_) | | | |
|___/\___/|_|\__,_|\__|_|\___/|_| |_|

;

%symdel reg acctt/nowarn;
data _null_;

   do i=1 to 3;

     call symputx('ct',put(i,3.));

     rc=dosubl('
       data qspecauto;
          set have1;
          if ct=&amp;amp;ct;
          call symputx ("reg",reg_predefined);
          call symputx ("acctt", reg_predefined);
       run;quit;

       data qnsause;
         set have2;
         if acctt= "&amp;amp;acctt";
       run;quit;
       proc reg data=qnsause outest = &amp;amp;reg(keep=_model_ _depvar_ intercept sales) ;
       &amp;amp;reg: model nsa=sales  ;
       run;quit;
     ');

   end;

run;quit;


1872  %symdel reg acctt/nowarn;
1873  data _null_;
1874     do i=1 to 3;
1875       call symputx('ct',put(i,3.));
1876       rc=dosubl('
1877         data qspecauto;
1878            set have1;
1879            if ct=&amp;amp;ct;
1880            call symputx ("reg",reg_predefined);
1881            call symputx ("acctt", reg_predefined);
1882         run;quit;
1883         data qnsause;
1884           set have2;
1885           if acctt= "&amp;amp;acctt";
1886         run;quit;
1887         proc reg data=qnsause outest = &amp;amp;reg(keep=_model_ _depvar_ intercept sales)
1888         &amp;amp;reg: model nsa=sales  ;
1889         run;quit;
1890       ');
1891     end;
1892  run;

SYMBOLGEN:  Macro variable CT resolves to 1
NOTE: There were 19 observations read from the data set WORK.HAVE1.
NOTE: The data set WORK.QSPECAUTO has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      memory              1028.06k
      OS Memory           20468.00k
      Timestamp           03/22/2017 07:05:41 PM
      Step Count                        464  Switch Count  0


SYMBOLGEN:  Macro variable ACCTT resolves to Alfred
NOTE: There were 57 observations read from the data set WORK.HAVE2.
NOTE: The data set WORK.QNSAUSE has 3 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      memory              1028.06k
      OS Memory           20468.00k
      Timestamp           03/22/2017 07:05:41 PM
      Step Count                        464  Switch Count  0


SYMBOLGEN:  Macro variable REG resolves to Alfred
SYMBOLGEN:  Macro variable REG resolves to Alfred
NOTE: The data set WORK.ALFRED has 1 observations and 4 variables.
NOTE: PROCEDURE REG used (Total process time):
      real time           0.09 seconds
      user cpu time       0.00 seconds
      system cpu time     0.04 seconds
      memory              2039.46k
      OS Memory           20980.00k
      Timestamp           03/22/2017 07:05:41 PM
      Step Count                        464  Switch Count  1



&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Mar 2017 23:08:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343532#M63397</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-03-22T23:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with macro vars resolving when used in proc X12 specs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343860#M63446</link>
      <description>&lt;P&gt;Even more info on the solution. The value of &amp;amp;reg was "td easter." This is an acceptable spec for regression inder the aictest&amp;nbsp;if you are using Census' Win X-13. I was interpreting that as being an acceptable spec for SAS proc X13&amp;nbsp;for predefined&amp;nbsp;regression. However, the X13 manual from SAS clearly states &lt;A href="https://support.sas.com/documentation/onlinedoc/ets/141/x13.pdf" target="_self"&gt;https://support.sas.com/documentation/onlinedoc/ets/141/x13.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"The predefined regression variables, EASTER, LABOR, SCEASTER, SINCOS, TDSTOCK, and THANK, require extra parameters."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"regression predefined=easter(7) easter(14);"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was the real problem. I needed to be more specific about which easter to use.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 20:36:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343860#M63446</guid>
      <dc:creator>alicek</dc:creator>
      <dc:date>2017-03-23T20:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with macro vars resolving when used in proc X12 specs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343863#M63447</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/135276"&gt;@alicek&lt;/a&gt;&amp;nbsp;Thanks for coming back and posting the answer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 20:39:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Issues-with-macro-vars-resolving-when-used-in-proc-X12-specs/m-p/343863#M63447</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-23T20:39:00Z</dc:date>
    </item>
  </channel>
</rss>

