<?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 macro with changing argument in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-with-changing-argument/m-p/10348#M764</link>
    <description>Hi everyone, I am more used to matlab data manipulation and find Sas&lt;BR /&gt;
synthesis difficult to understand sometimes.&lt;BR /&gt;
&lt;BR /&gt;
Suppose the macro 'prog_iter' is programmed correctly. It takes a value 'k'&lt;BR /&gt;
as input. My question is how to use do-loop to let k being different values .&lt;BR /&gt;
(Eg. for k=0.&lt;BR /&gt;
01 to 1 by step of 0.01) or any ways. &lt;BR /&gt;
&lt;BR /&gt;
Thank you in advance&lt;BR /&gt;
----------------------------------------------------------------------&lt;BR /&gt;
   %prog_iter(k=0);&lt;BR /&gt;
   %prog_iter(k=0.01);&lt;BR /&gt;
   %prog_iter(k=0.02);</description>
    <pubDate>Thu, 09 Jun 2011 13:54:15 GMT</pubDate>
    <dc:creator>telescopic</dc:creator>
    <dc:date>2011-06-09T13:54:15Z</dc:date>
    <item>
      <title>macro with changing argument</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-changing-argument/m-p/10348#M764</link>
      <description>Hi everyone, I am more used to matlab data manipulation and find Sas&lt;BR /&gt;
synthesis difficult to understand sometimes.&lt;BR /&gt;
&lt;BR /&gt;
Suppose the macro 'prog_iter' is programmed correctly. It takes a value 'k'&lt;BR /&gt;
as input. My question is how to use do-loop to let k being different values .&lt;BR /&gt;
(Eg. for k=0.&lt;BR /&gt;
01 to 1 by step of 0.01) or any ways. &lt;BR /&gt;
&lt;BR /&gt;
Thank you in advance&lt;BR /&gt;
----------------------------------------------------------------------&lt;BR /&gt;
   %prog_iter(k=0);&lt;BR /&gt;
   %prog_iter(k=0.01);&lt;BR /&gt;
   %prog_iter(k=0.02);</description>
      <pubDate>Thu, 09 Jun 2011 13:54:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-changing-argument/m-p/10348#M764</guid>
      <dc:creator>telescopic</dc:creator>
      <dc:date>2011-06-09T13:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: macro with changing argument</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-changing-argument/m-p/10349#M765</link>
      <description>See &lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000543697.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000543697.htm&lt;/A&gt;</description>
      <pubDate>Thu, 09 Jun 2011 14:56:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-changing-argument/m-p/10349#M765</guid>
      <dc:creator>polingjw</dc:creator>
      <dc:date>2011-06-09T14:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: macro with changing argument</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-changing-argument/m-p/10350#M766</link>
      <description>you may find that you could insert a %DO loop inside the macro where you want to do some looping. &lt;BR /&gt;
Alternatively you can create a wrapper macro that will derive the value you want to supply and then call your %prog_iter. Something like this untested code:&lt;BR /&gt;
 &lt;BR /&gt;
%macro looping( from_value= 0, to_value= 1, by_val= .01 );&lt;BR /&gt;
%* but because simple old sas macro iterative %do from/to/by looping expects integers, ...;&lt;BR /&gt;
%let this val = &amp;amp;from_val ;&lt;BR /&gt;
%do %while( %sysevalf( &amp;amp;this_val LE &amp;amp;to_val ) ;  &lt;BR /&gt;
%prog_iter(  k= &amp;amp;this_val ) &lt;BR /&gt;
%let this_val = %sysevalf( &amp;amp;this_val + &amp;amp;by_val ) ;&lt;BR /&gt;
%end ; &lt;BR /&gt;
%mend  looping ;&lt;BR /&gt;
which you could invoke with&lt;BR /&gt;
%looping( from_value= .01, to_value= .9, by_val= .015 )&lt;BR /&gt;
  &lt;BR /&gt;
but be very careful before extending the use of this %looping to negative &amp;amp;by_val &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;
 &lt;BR /&gt;
peterC</description>
      <pubDate>Thu, 09 Jun 2011 16:02:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-changing-argument/m-p/10350#M766</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-06-09T16:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: macro with changing argument</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-changing-argument/m-p/10351#M767</link>
      <description>Hi,&lt;BR /&gt;
  This is a good paper that explains the basics of macro processing. It covers what a macro program is and why you can only use %IF and %DO in a macro program (Step 9). &lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi28/056-28.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi28/056-28.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
  Of course, you'll need to read the rest of the steps and understand them before you proceed.&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 09 Jun 2011 17:09:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-changing-argument/m-p/10351#M767</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-06-09T17:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: macro with changing argument</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-changing-argument/m-p/10352#M768</link>
      <description>I understand what polingjw 	want to point out. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%macro prog_iter(k=);&lt;BR /&gt;
 %put k=&amp;amp;k;&lt;BR /&gt;
%mend prog_iter;&lt;BR /&gt;
&lt;BR /&gt;
Data _null_;&lt;BR /&gt;
 do i=0.1 to 1 by 0.1;&lt;BR /&gt;
  call execute('%prog_iter(k='||i||')');&lt;BR /&gt;
 end;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Fri, 10 Jun 2011 03:01:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-changing-argument/m-p/10352#M768</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-10T03:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: macro with changing argument</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-changing-argument/m-p/10353#M769</link>
      <description>The call execute method is clean and clear. Macro wrapper method is instructive too. Before that, I was even thinking how to let the %pro_iterate(k=) to accept a sas data set as input, which has values 0.01, 0.02,... 0.10 !&lt;BR /&gt;
&lt;BR /&gt;
Thank all of you.</description>
      <pubDate>Fri, 10 Jun 2011 19:39:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-changing-argument/m-p/10353#M769</guid>
      <dc:creator>telescopic</dc:creator>
      <dc:date>2011-06-10T19:39:02Z</dc:date>
    </item>
  </channel>
</rss>

