<?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: Macro parameter to repeat the value for n times in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-to-repeat-the-value-for-n-times/m-p/885818#M350048</link>
    <description>&lt;P&gt;The N provided to REPEAT() is the number of EXTRA copies to create.&amp;nbsp; So subtract one.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put %sysfunc(repeat(&amp;amp;name,&amp;amp;n-1)) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jul 2023 13:31:04 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-07-21T13:31:04Z</dc:date>
    <item>
      <title>Macro parameter to repeat the value for n times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-to-repeat-the-value-for-n-times/m-p/885785#M350037</link>
      <description>&lt;P&gt;Any leads on macro program to repeat the value for 'n' times? Assume I have the macro variables called 'name' and 'n'. If the value is 'David' and '100' then I want the name to print 100 times in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Desired Output:&lt;/STRONG&gt; 100 times value of name should be printed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;
&lt;P&gt;.....&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2023 10:36:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-to-repeat-the-value-for-n-times/m-p/885785#M350037</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2023-07-21T10:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Macro parameter to repeat the value for n times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-to-repeat-the-value-for-n-times/m-p/885787#M350038</link>
      <description>&lt;P&gt;Bizarre request. I get the feeling there's a lot more you haven't told us ... however a very simple do-loop works&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let name=David;
%let n=100;

%macro do_this;
&amp;nbsp; &amp;nbsp; &amp;nbsp;%do i=1 %to &amp;amp;n;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %put &amp;amp;name;
&amp;nbsp; &amp;nbsp; &amp;nbsp;%end;
%mend;
%do_this&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2023 13:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-to-repeat-the-value-for-n-times/m-p/885787#M350038</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-07-21T13:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Macro parameter to repeat the value for n times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-to-repeat-the-value-for-n-times/m-p/885808#M350046</link>
      <description>&lt;P&gt;EDIT:&lt;/P&gt;
&lt;P&gt;Sorry, off-by-one error below.&amp;nbsp; I hate that the developer of REPEAT() thought it should return the first argument n+1 times.&amp;nbsp; So to have David appear 100 times, you need:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put %sysfunc(repeat(&amp;amp;name,&amp;amp;n-1)) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a REPEAT function, so you can do it without a macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let name=David ;
%let n=100 ;
%put %sysfunc(repeat(&amp;amp;name,&amp;amp;n)) ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jul 2023 13:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-to-repeat-the-value-for-n-times/m-p/885808#M350046</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-07-21T13:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Macro parameter to repeat the value for n times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-to-repeat-the-value-for-n-times/m-p/885818#M350048</link>
      <description>&lt;P&gt;The N provided to REPEAT() is the number of EXTRA copies to create.&amp;nbsp; So subtract one.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put %sysfunc(repeat(&amp;amp;name,&amp;amp;n-1)) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2023 13:31:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-to-repeat-the-value-for-n-times/m-p/885818#M350048</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-21T13:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: Macro parameter to repeat the value for n times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-to-repeat-the-value-for-n-times/m-p/885819#M350049</link>
      <description>&lt;P&gt;Thanks Tom, I only remembered that while I finished my breakfast. : )&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2023 13:34:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-to-repeat-the-value-for-n-times/m-p/885819#M350049</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-07-21T13:34:03Z</dc:date>
    </item>
  </channel>
</rss>

