<?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: SAS macro problems in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770153#M244301</link>
    <description>&lt;P&gt;I'm very sorry for wasting your time, and I would like to express my heartfelt thanks for your help!&lt;/P&gt;</description>
    <pubDate>Fri, 24 Sep 2021 08:37:49 GMT</pubDate>
    <dc:creator>Phoenix_LJ</dc:creator>
    <dc:date>2021-09-24T08:37:49Z</dc:date>
    <item>
      <title>SAS macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770142#M244292</link>
      <description>&lt;UL&gt;&lt;LI&gt;&lt;P class="src grammarSection"&gt;Thank you very much, but I'd like to ask you a question. Thank you&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Code as follws:&lt;/P&gt;&lt;PRE&gt;%macro Sets(start,end,prefix);
%do i = start %to end;
	&amp;amp;prefix.||&amp;amp;i.||' ' 
%end;
%mend; &lt;BR /&gt;%Sets(2005,2050,data);&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class="src grammarSection"&gt;I want to generate a program like this:&lt;/P&gt;&lt;PRE&gt;data2005 data2006 data2007 ......data2050;&lt;/PRE&gt;But my macro does not run successfully, how to modify this macro program&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Fri, 24 Sep 2021 08:08:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770142#M244292</guid>
      <dc:creator>Phoenix_LJ</dc:creator>
      <dc:date>2021-09-24T08:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770144#M244294</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class="src grammarSection"&gt;I want to use this macro program for the following program&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WeekOfDate;
	set %sets(start=2005,end=2020,prefix=data);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Sep 2021 08:12:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770144#M244294</guid>
      <dc:creator>Phoenix_LJ</dc:creator>
      <dc:date>2021-09-24T08:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770145#M244295</link>
      <description>&lt;P&gt;A few corrections.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Start, end and prefix are now macro variables. That means you should reference them with &amp;amp;.&lt;/LI&gt;
&lt;LI&gt;The macro language is a text language. Consider everything as text. This means that the concatenation operators are redundant and so is the ' ' in the end.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;To test if your macro (function) returns the correct result, test it with a %Put Statement as below.&amp;nbsp;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Hope this helps &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro Sets(start,end,prefix);
%do i = &amp;amp;start. %to &amp;amp;end.;
&amp;amp;prefix.&amp;amp;i.
%end;
%mend; 


%put %Sets(2005,2050,data);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Sep 2021 08:15:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770145#M244295</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-09-24T08:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770147#M244296</link>
      <description>&lt;P&gt;To use macro parameters in the macro, you need to address them like macro variables, and you do not need concatenation operators, as in macro everything is text:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Sets(start,end,prefix);
%do i = &amp;amp;start. %to &amp;amp;end.;
	&amp;amp;prefix.&amp;amp;i 
%end;
%mend; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can use this like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set
  &amp;amp;sets(2005,2050,data)
; /* this semicolon is NOT part of the macro call, it terminates the SET statement! */
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Sep 2021 08:19:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770147#M244296</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-24T08:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770150#M244298</link>
      <description>&lt;P&gt;&lt;SPAN&gt;First of all, thank you very much.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But,if you have two data set names 'data2005','data2006'。&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;now,use programs as follows:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*define*/
%macro Sets(start,end,prefix);
%do i = &amp;amp;start. %to &amp;amp;end.;
	&amp;amp;prefix.&amp;amp;i. 
%end;
%mend; 


data a;
set
%Set(2005,2006,data)
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;P class="src grammarSection" data-group="1-1"&gt;Unfortunately, the program will not run。&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 24 Sep 2021 08:33:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770150#M244298</guid>
      <dc:creator>Phoenix_LJ</dc:creator>
      <dc:date>2021-09-24T08:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770151#M244299</link>
      <description>&lt;P&gt;You define macro Set&lt;FONT color="#FF0000"&gt;s&lt;/FONT&gt;, but you use macro set (missing s).&lt;/P&gt;
&lt;P&gt;If something else is the issue, please post the complete log of the data step, using this button:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54552i914D97BE1B0F21E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 08:35:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770151#M244299</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-24T08:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770152#M244300</link>
      <description>&lt;P&gt;Why does it not run? What does the log say?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 08:37:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770152#M244300</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-09-24T08:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770153#M244301</link>
      <description>&lt;P&gt;I'm very sorry for wasting your time, and I would like to express my heartfelt thanks for your help!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 08:37:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770153#M244301</guid>
      <dc:creator>Phoenix_LJ</dc:creator>
      <dc:date>2021-09-24T08:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770154#M244302</link>
      <description>&lt;P&gt;Proof of concept:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data2005;
set sashelp.class;
run;

data data2006;
set sashelp.class;
run;

%macro Sets(start,end,prefix);
%do i = &amp;amp;start. %to &amp;amp;end.;
	&amp;amp;prefix.&amp;amp;i 
%end;
%mend; 

data want;
set
%Sets(2005,2006,data)
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Sep 2021 08:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770154#M244302</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-24T08:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770156#M244303</link>
      <description>thanks for your help!&lt;BR /&gt;This is a question that should not arise!</description>
      <pubDate>Fri, 24 Sep 2021 08:41:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770156#M244303</guid>
      <dc:creator>Phoenix_LJ</dc:creator>
      <dc:date>2021-09-24T08:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770159#M244305</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/307532"&gt;@Phoenix_LJ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm very sorry for wasting your time, and I would like to express my heartfelt thanks for your help!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Really no waste, sometimes a second set of eyes is needed. Been there, done that, have the T-shirt.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Might be material for another Maxim.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 08:45:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-problems/m-p/770159#M244305</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-24T08:45:38Z</dc:date>
    </item>
  </channel>
</rss>

