<?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: How to set a macro variable that has '+' and is used in the proc model step? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673880#M202803</link>
    <description>&lt;P&gt;Hi! The log informs me to define the variable preceding proc model. But I need to change the 'indep' with other variables in this macro each time. If I use the %let statement in the macro, it seems I have to change this variable in the macro. Can I just change it each time with other macro variables together when calling this macro? Many thanks for your help!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 01 Aug 2020 08:13:57 GMT</pubDate>
    <dc:creator>xizidememeda</dc:creator>
    <dc:date>2020-08-01T08:13:57Z</dc:date>
    <item>
      <title>How to set a macro variable that has '+' and is used in the proc model step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673825#M202776</link>
      <description>&lt;P&gt;Hi guys! Could you please give me some help for my urgent question on setting a macro variable? I will appreciate it very much for your warm help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to set a macro variable 'indep =&amp;nbsp;a + b1* mkt + b2 * smb + b3 * hml' and use it in the following proc model step. However, it doesn't work. How can I set a macro variable which has '+' signs in this situation? Your answer will help me a lot!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc model data=ret_5; 
	 by  id;
	 parms a b1 b2 b3;
	 instruments mkt smb hml;
	 exret = &amp;amp;indep; 
	 fit exret / gmm kernel=(bart, 2, 0);
	 ods output parameterestimates=cs;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Jul 2020 20:19:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673825#M202776</guid>
      <dc:creator>xizidememeda</dc:creator>
      <dc:date>2020-07-31T20:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a macro variable that has '+' and is used in the proc model step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673832#M202782</link>
      <description>&lt;P&gt;Have you tried to precede proc model by next statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let indep = a + b1* mkt + b2 * smb + b3 * hml;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;thus assigning the value to the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if positive, then explain what do yo mean by "&lt;STRONG&gt;&lt;SPAN&gt;it doesn't&lt;/SPAN&gt;&lt;/STRONG&gt; work." ?&lt;/P&gt;
&lt;P&gt;In such case better post the log with your explanatin.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2020 21:04:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673832#M202782</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-07-31T21:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a macro variable that has '+' and is used in the proc model step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673839#M202786</link>
      <description>&lt;P&gt;Really, you need to show how you build your macro variable INDEP&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2020 21:54:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673839#M202786</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-31T21:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a macro variable that has '+' and is used in the proc model step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673880#M202803</link>
      <description>&lt;P&gt;Hi! The log informs me to define the variable preceding proc model. But I need to change the 'indep' with other variables in this macro each time. If I use the %let statement in the macro, it seems I have to change this variable in the macro. Can I just change it each time with other macro variables together when calling this macro? Many thanks for your help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Aug 2020 08:13:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673880#M202803</guid>
      <dc:creator>xizidememeda</dc:creator>
      <dc:date>2020-08-01T08:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a macro variable that has '+' and is used in the proc model step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673881#M202804</link>
      <description>&lt;P&gt;Would you prefer the code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let test =  a + b1* mkt + b2 * smb + b3 * hml;
proc model data=ret_5; 
	 by  id;
	 parms a b1 b2 b3;
	 instruments mkt smb hml;
	 exret = indep = &amp;amp;test;    /* any time replace the indep into wanted variable */ 
	 fit exret / gmm kernel=(bart, 2, 0);
	 ods output parameterestimates=cs;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Aug 2020 09:24:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673881#M202804</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-08-01T09:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a macro variable that has '+' and is used in the proc model step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673882#M202805</link>
      <description>&lt;P&gt;Hi~Thanks for your reply! But it seems I still need to change the &lt;EM&gt;test&lt;/EM&gt; variable each time in the macro, right?&lt;/P&gt;</description>
      <pubDate>Sat, 01 Aug 2020 09:32:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673882#M202805</guid>
      <dc:creator>xizidememeda</dc:creator>
      <dc:date>2020-08-01T09:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a macro variable that has '+' and is used in the proc model step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673883#M202806</link>
      <description>&lt;P&gt;Alternatively you may prefer next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let formula =  a + b1* mkt + b2 * smb + b3 * hml;

%macro p_model(var,tst,dsn=ret_5);
proc model data=&amp;amp;dsn; 
	 by  id;
	 parms a b1 b2 b3;
	 instruments mkt smb hml;
	 exret = &amp;amp;var = &amp;amp;tst ;   
	 fit exret / gmm kernel=(bart, 2, 0);
	 ods output parameterestimates=cs;
quit;
%mend p_model;

%p_model(indep,&amp;amp;formula);  /* input = ret_5 the default dataset */

%p_model(anyvar,&amp;amp;formula );  

%p_model(new_var, &amp;lt;new_formula&amp;gt;, dsn=&amp;lt;any_dataset&amp;gt;);&amp;nbsp;/*&amp;nbsp;any&amp;nbsp;other&amp;nbsp;input&amp;nbsp;*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Aug 2020 17:39:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673883#M202806</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-08-01T17:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a macro variable that has '+' and is used in the proc model step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673892#M202813</link>
      <description>&lt;P&gt;Thanks! Could you please give me a little more explanations? I don't understand what the meaning of 'exret = &amp;amp;var = &amp;amp;formula' is. What's more, when using &amp;amp;macro (indep=), it seems I have already define a macro variable &lt;EM&gt;indep&lt;/EM&gt; and I can directly call&amp;nbsp;&lt;EM&gt;indep&lt;/EM&gt; by using %macro (indep= a + b1* mkt + b2 * smb + b3 * hml);, why I need to define the variable again?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Aug 2020 10:52:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673892#M202813</guid>
      <dc:creator>xizidememeda</dc:creator>
      <dc:date>2020-08-01T10:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a macro variable that has '+' and is used in the proc model step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673893#M202814</link>
      <description>&lt;P&gt;&lt;SPAN&gt;The log reports: All positional parameter variables in the %MACRO statement must be&lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt; listed before&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt; any&amp;nbsp;keyword parameter variable is listed&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Aug 2020 10:59:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673893#M202814</guid>
      <dc:creator>xizidememeda</dc:creator>
      <dc:date>2020-08-01T10:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a macro variable that has '+' and is used in the proc model step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673894#M202815</link>
      <description>&lt;P&gt;Hi! I have revised my code based on your suggestion and it works now! Thanks soooo much!&lt;/P&gt;</description>
      <pubDate>Sat, 01 Aug 2020 11:06:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673894#M202815</guid>
      <dc:creator>xizidememeda</dc:creator>
      <dc:date>2020-08-01T11:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a macro variable that has '+' and is used in the proc model step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673899#M202820</link>
      <description>&lt;P&gt;A short explanation to macro programming:&lt;/P&gt;
&lt;P&gt;1) Assigning a value to a &lt;STRONG&gt;macro variable&lt;/STRONG&gt; is done by:&lt;/P&gt;
&lt;PRE&gt;%LET &amp;lt;macro_variable_name&amp;gt; = any string;&lt;/PRE&gt;
&lt;P&gt;2) Defining a &lt;STRONG&gt;macro program&lt;/STRONG&gt; is done by:&lt;/P&gt;
&lt;PRE&gt;%MACRO &amp;lt;macro_program_name&amp;gt;(arguments seaparated by comma);
       ... sas code to run ...
       ... using &amp;amp;&amp;lt;macro_variable&amp;gt; or &amp;amp;&amp;lt;argument&amp;gt; to be replaced at run time
             by their assigned value 
       .........
%MEND [&amp;lt;macro_program_name&amp;gt;];  /* closes the macro program */

%&amp;lt;macro_program_name&amp;gt;( assigned arguments); /* execute the macro program */&lt;/PRE&gt;
&lt;P&gt;3) There are two kinds of arguments that can be defined with a macro program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;3.1) &lt;STRONG&gt;positional arguments&lt;/STRONG&gt; must be given in same order as defined in the macro program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;3.2) &lt;STRONG&gt;named arguments&lt;/STRONG&gt; must follow &lt;STRONG&gt;after&lt;/STRONG&gt; all positional arguments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; You can assign a &lt;STRONG&gt;default value&lt;/STRONG&gt; to named argument only, and&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; you can override the default value at invoking the macro program to be executed;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is much more to learn about &lt;STRONG&gt;macro language .&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Welcome to a new sas field.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Aug 2020 12:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-macro-variable-that-has-and-is-used-in-the-proc/m-p/673899#M202820</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-08-01T12:10:56Z</dc:date>
    </item>
  </channel>
</rss>

