<?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 make a Variable  macro that the Input parameters can be changed in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/make-a-Variable-macro-that-the-Input-parameters-can-be-changed/m-p/596015#M171558</link>
    <description>&lt;P&gt;Dear ALL:&lt;/P&gt;&lt;P&gt;I want to make a Variable macro that the Input parameters can be changed (here i want to control the default value of every parameter) ,so that the macro can be changed:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I try like this :&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%let name=%str(name1=zs,name2=ls,name3=,name4=,name5=hh);&lt;BR /&gt;%macro test(&amp;amp;name.);&lt;BR /&gt;%put &amp;amp;name1. is a good man;&lt;BR /&gt;%put &amp;amp;name2. is a good man;&lt;/P&gt;&lt;P&gt;%put &amp;amp;name3. is a good man;&lt;/P&gt;&lt;P&gt;%put &amp;amp;name4. is a good man;&lt;/P&gt;&lt;P&gt;%put &amp;amp;name5. is a good man;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;but failed;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ANY suggestion is welcome ！Thanks in advance！&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 13 Oct 2019 01:17:59 GMT</pubDate>
    <dc:creator>duanzongran</dc:creator>
    <dc:date>2019-10-13T01:17:59Z</dc:date>
    <item>
      <title>make a Variable  macro that the Input parameters can be changed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-a-Variable-macro-that-the-Input-parameters-can-be-changed/m-p/596015#M171558</link>
      <description>&lt;P&gt;Dear ALL:&lt;/P&gt;&lt;P&gt;I want to make a Variable macro that the Input parameters can be changed (here i want to control the default value of every parameter) ,so that the macro can be changed:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I try like this :&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%let name=%str(name1=zs,name2=ls,name3=,name4=,name5=hh);&lt;BR /&gt;%macro test(&amp;amp;name.);&lt;BR /&gt;%put &amp;amp;name1. is a good man;&lt;BR /&gt;%put &amp;amp;name2. is a good man;&lt;/P&gt;&lt;P&gt;%put &amp;amp;name3. is a good man;&lt;/P&gt;&lt;P&gt;%put &amp;amp;name4. is a good man;&lt;/P&gt;&lt;P&gt;%put &amp;amp;name5. is a good man;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;but failed;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ANY suggestion is welcome ！Thanks in advance！&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2019 01:17:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-a-Variable-macro-that-the-Input-parameters-can-be-changed/m-p/596015#M171558</guid>
      <dc:creator>duanzongran</dc:creator>
      <dc:date>2019-10-13T01:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: make a Variable  macro that the Input parameters can be changed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-a-Variable-macro-that-the-Input-parameters-can-be-changed/m-p/596019#M171560</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266020"&gt;@duanzongran&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;In the %macro statement, the macro processor looks for (a) macro name that is a valid SAS identifier and and (b) parameter name that is a valid SAS identifier. Your "parameter name" starts with &amp;amp;, which is not valid. If you want, as you say, to control the default value of every parameter, just define the macro with:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test (name1=zs, name2=ls, name3=, name4=, name5=hh) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and change the parameter values as needed at macro invocations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2019 01:48:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-a-Variable-macro-that-the-Input-parameters-can-be-changed/m-p/596019#M171560</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-10-13T01:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: make a Variable  macro that the Input parameters can be changed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-a-Variable-macro-that-the-Input-parameters-can-be-changed/m-p/596021#M171561</link>
      <description>&lt;P&gt;Only use below if you really need to pass-in a variable list of parameters. This is rarely required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The %macro parmbuff options allows you to pass in a variable list of parameters.&lt;/P&gt;
&lt;P&gt;These parameters then become available in your macro via automatic macro variable &amp;amp;syspbuff.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test/parmbuff;
    %put macro contains : &amp;amp;syspbuff;
    %let cnt = %sysfunc(countw(&amp;amp;syspbuff));
    %do i = 1 %to &amp;amp;cnt;
        %put %scan(&amp;amp;syspbuff, &amp;amp;i) is a good man;
    %end;
%mend test;                                                                                                                            
 
%test(zs,ls,hh);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=p1nypovnwon4uyn159rst8pgzqrl.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://go.documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=p1nypovnwon4uyn159rst8pgzqrl.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2019 02:04:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-a-Variable-macro-that-the-Input-parameters-can-be-changed/m-p/596021#M171561</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-10-13T02:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: make a Variable  macro that the Input parameters can be changed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-a-Variable-macro-that-the-Input-parameters-can-be-changed/m-p/596030#M171568</link>
      <description>&lt;P&gt;You cannot use macro code to generate the %MACRO statement.&lt;/P&gt;
&lt;P&gt;You could try use some other method of code&amp;nbsp; generation to build your macro definition, such as writing code to a file and %INCLUDING it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it is very likely there is another way to do what you really want to do. So if you can explain that then perhaps someone can help you.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://xyproblem.info/" target="_blank"&gt;http://xyproblem.info/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2019 04:22:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-a-Variable-macro-that-the-Input-parameters-can-be-changed/m-p/596030#M171568</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-13T04:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: make a Variable  macro that the Input parameters can be changed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-a-Variable-macro-that-the-Input-parameters-can-be-changed/m-p/598302#M172539</link>
      <description>&lt;P&gt;THANK YOU &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;;&lt;/P&gt;&lt;P&gt;here i do a further describtion and hope to get &amp;nbsp;your &lt;SPAN&gt;Valuable advice &amp;nbsp;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HERE IS WHAT I HAVE&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have three macros ,macro3 refers to macro2 and macro2 refers to macro1,&lt;/P&gt;&lt;P&gt;and &lt;SPAN&gt;They share the same input parameters (name1=,name2=,name3=,name4=,name5=);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro macro1(name1=,name2=,name3=,name4=,name5=);&lt;BR /&gt;*codes......;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro macro2(x1=,x2=,name1=,name2=,name3=,name4=,name5=);&lt;BR /&gt;*other codes.......;&lt;BR /&gt;%macro1(name1=&amp;amp;name1.,name2=&amp;amp;name2.,name3=&amp;amp;name3.,name4=&amp;amp;name4.,name5=&amp;amp;name5.);&lt;BR /&gt;*other codes.......;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro macro3(y1=,y2=,x1=,x2=,name1=,name2=,name3=,name4=,name5=);&lt;BR /&gt;*other codes.......;&lt;BR /&gt;%macro2(x1=&amp;amp;x1.,x2=&amp;amp;x2.,name1=&amp;amp;name1.,name2=&amp;amp;name2.,name3=&amp;amp;name3.,name4=&amp;amp;name4.,name5=&amp;amp;name5.);&lt;BR /&gt;*other codes.......;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HERE IS WHAT I WANT&amp;nbsp;&lt;/P&gt;&lt;P&gt;CONTROL THE INPUT&amp;nbsp;&lt;SPAN&gt;parameters OF EVERY MACRO BY MACRO VARIABLE ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;the number of&amp;nbsp;&lt;SPAN&gt; input parameters of macro1 may be changed to&amp;nbsp; (name1=,name2=,name3=,name4=,name5=,name6=,name7=) or more,just like&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%macro macro1(name1=,name2=,name3=,name4=,name5=,name6=,name7=);&lt;BR /&gt;*codes......;&lt;BR /&gt;%mend;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and i wish macro2 could be changed as&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%macro macro2&amp;nbsp;(x1=,x2=,name1=,name2=,name3=,name4=,name5=,name6=,name7=);&lt;BR /&gt;*other codes.......;&lt;BR /&gt;%macro1(name1=&amp;amp;name1.,name2=&amp;amp;name2.,name3=&amp;amp;name3.,name4=&amp;amp;name4.,name5=&amp;amp;name5.,name6=&amp;amp;name6.,name7=&amp;amp;name7);&lt;BR /&gt;*other codes.......;&lt;BR /&gt;%mend;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and i wish macro3 &amp;nbsp;could be changed as&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%macro macro3(y1=,y2=,x1=,x2=,name1=,name2=,name3=,name4=,name5=,name6=,name7=);&lt;BR /&gt;*other codes.......;&lt;BR /&gt;%macro2(x1=&amp;amp;x1.,x2=x2.,name1=&amp;amp;name1.,name2=&amp;amp;name2.,name3=&amp;amp;name3.,name4=&amp;amp;name4.,name5=&amp;amp;name5.,name6=&amp;amp;name6.,name7=&amp;amp;name7);&lt;BR /&gt;*other codes.......;&lt;BR /&gt;%mend;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 03:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-a-Variable-macro-that-the-Input-parameters-can-be-changed/m-p/598302#M172539</guid>
      <dc:creator>duanzongran</dc:creator>
      <dc:date>2019-10-22T03:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: make a Variable  macro that the Input parameters can be changed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-a-Variable-macro-that-the-Input-parameters-can-be-changed/m-p/598394#M172562</link>
      <description>&lt;P&gt;That doesn't make any sense.&amp;nbsp; When you write the macro you decide the what input it takes.&amp;nbsp; Why would you want to change that without changing the macro?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the issue that you want to pass a variable number of VALUES to the macro when your CALL the macro?&amp;nbsp; If so then just design the macro to accept a variable number of values.&amp;nbsp; The easiest what to do that is to just use one parameter and pass the values in as a list.&amp;nbsp; You can use space or | or some other character as the delimiter between the values.&amp;nbsp; You could&amp;nbsp; even use comma as the delimiter, but then the call is going to be difficult.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro macro1(name_list);
%local i n_names name;
%let n_names=%sysfunc(countw(&amp;amp;name_list,%str( )));
%do i=1 %to &amp;amp;n_names;
  %let name=%scan(&amp;amp;name_list,&amp;amp;i,%str( ));
   ...
%end;
%mend;

%macro macro2(x_list,name_list);
...
  %macro1(name_list=&amp;amp;name_list)
...
%mend;

%macro2(x_list=x1_value x2_value,name_list=Name1 Name2 Name3);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Oct 2019 13:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-a-Variable-macro-that-the-Input-parameters-can-be-changed/m-p/598394#M172562</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-22T13:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: make a Variable  macro that the Input parameters can be changed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-a-Variable-macro-that-the-Input-parameters-can-be-changed/m-p/598653#M172655</link>
      <description>Thank U ! variable_list is a good method!</description>
      <pubDate>Wed, 23 Oct 2019 10:20:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-a-Variable-macro-that-the-Input-parameters-can-be-changed/m-p/598653#M172655</guid>
      <dc:creator>duanzongran</dc:creator>
      <dc:date>2019-10-23T10:20:52Z</dc:date>
    </item>
  </channel>
</rss>

