<?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: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf in Advanced Programming</title>
    <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/962458#M327</link>
    <description>&lt;P&gt;My comments in this post also apply to the practice question (level-challenge) on page 317 of SAS SQL1: Essentials course note PDF, the question and answer code (which I guess I would not use the code if there is any other alternative I can choose) are as follows:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_0-1742668923886.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105591i1492C5E289FB0C8F/image-size/large?v=v2&amp;amp;px=999" role="button" title="dxiao2017_0-1742668923886.png" alt="dxiao2017_0-1742668923886.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_1-1742669032919.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105592i3B539559FEE39C36/image-size/large?v=v2&amp;amp;px=999" role="button" title="dxiao2017_1-1742669032919.png" alt="dxiao2017_1-1742669032919.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And have to say &lt;EM&gt;countw()&lt;/EM&gt; function is not good here because the character string is complex (has several ampersand&lt;EM&gt;&amp;amp;&lt;/EM&gt; and one hyphen&lt;EM&gt;-&lt;/EM&gt;) and struggle many times using&amp;nbsp;&lt;EM&gt;%nrstr&lt;/EM&gt;&amp;nbsp; to deal with delimiters (and this till now I do not think I can figure out the thorough and detailed usage) was not able to fix the errors (see below). The best solution perhaps is the &lt;EM&gt;select into :list1-&lt;/EM&gt; and &lt;EM&gt;%do i=1 %to &amp;amp;sqlobs&lt;/EM&gt; one.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_0-1742671324593.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105593i9B6742DB1805F2BC/image-size/large?v=v2&amp;amp;px=999" role="button" title="dxiao2017_0-1742671324593.png" alt="dxiao2017_0-1742671324593.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* %put &amp;amp;regionvalue; */
/*  */
/* %let n=%sysfunc(countw(a&amp;amp;b,c&amp;amp;d,e&amp;amp;f,g-h)); */
/* %put &amp;amp;n; */
/*  */
/* %let n=%sysfunc(countw(&amp;amp;regionvalue)); */
/* %put &amp;amp;n; */
/*  */
/* %let string=%nrstr(&amp;amp;regionvalue); */
/* %put &amp;amp;string; */
/* %let i=%sysfunc(countw(&amp;amp;string,',')); */
/* %put &amp;amp;i; */&lt;BR /&gt;
%macro split(tab,col);
proc sql;
select distinct &amp;amp;col
   into :colvalue1-
   from &amp;amp;tab
   where &amp;amp;col^=' ';
quit;
%do i=1 %to &amp;amp;sqlobs;
proc sql;
select *
   from &amp;amp;tab
   where &amp;amp;col="&amp;amp;&amp;amp;colvalue&amp;amp;i";
quit;
%end;
%mend split;
%split(sq.globalmetadata,region);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 22 Mar 2025 19:24:36 GMT</pubDate>
    <dc:creator>dxiao2017</dc:creator>
    <dc:date>2025-03-22T19:24:36Z</dc:date>
    <item>
      <title>Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960866#M280</link>
      <description>&lt;P&gt;The question asks to produce means statistics for a list of number of years for the input dataset, and suggests using a %do %until statement and a %scan function inside a macro to do it. The solution offered is as follows:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_0-1741108962376.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105154i9B61BCFC8A039419/image-size/large?v=v2&amp;amp;px=999" role="button" title="dxiao2017_0-1741108962376.png" alt="dxiao2017_0-1741108962376.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;For me, this solution is a little bit confusing and complicated because of 1) the %do %until statement is written in a not so frequently used way, i.e., without the i=xxx to xxx part and 2) the logic behind the repeated %let i= and %let yr= is difficult to understand. I think my solution(below) is simpler and easier (without the %do %until and use a %sysfunc(countw) instead) to produce reports or statistics for a list of years (or any other lists of things, as a macro variable).&lt;/P&gt;
&lt;PRE&gt;%macro storms(list);&lt;BR /&gt;%let count=%sysfunc(countw(&amp;amp;list));&lt;BR /&gt;%do i=1 %to &amp;amp;count;&lt;BR /&gt;   %let yr=%scan(&amp;amp;list,&amp;amp;i);&lt;BR /&gt;   title "&amp;amp;yr Storms";&lt;BR /&gt;   proc means data=mc1.storm_final n min &lt;BR /&gt;                    mean max maxdec=0;&lt;BR /&gt;      var MaxWindMPH MinPressure;&lt;BR /&gt;      where season=&amp;amp;yr;&lt;BR /&gt;   run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend storms;&lt;BR /&gt;%storms(2011 2012 2014);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_1-1741110157644.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105155iAC2FB62E24D41B9F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dxiao2017_1-1741110157644.png" alt="dxiao2017_1-1741110157644.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 17:50:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960866#M280</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-03-04T17:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960868#M281</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466238"&gt;@dxiao2017&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The question asks to produce means statistics for a list of number of years for the input dataset, and suggests using a %do %until statement and a %scan function inside a macro to do it. The solution offered is as follows:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_0-1741108962376.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105154i9B61BCFC8A039419/image-size/large?v=v2&amp;amp;px=999" role="button" title="dxiao2017_0-1741108962376.png" alt="dxiao2017_0-1741108962376.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;For me, this solution is a little bit confusing and complicated because of 1) the %do %until statement is written in a not so frequently used way, i.e., without the i=xxx to xxx part and 2) the logic behind the repeated %let i= and %let yr= is difficult to understand. I think my solution(below) is simpler and easier (without the %do %until and use a %sysfunc(countw) instead) to produce reports or statistics for a list of years (or any other lists of things, as a macro variable).&lt;/P&gt;
&lt;PRE&gt;%macro storms(list);&lt;BR /&gt;%let count=%sysfunc(countw(&amp;amp;list));&lt;BR /&gt;%do i=1 %to &amp;amp;count;&lt;BR /&gt;   %let yr=%scan(&amp;amp;list,&amp;amp;i);&lt;BR /&gt;   title "&amp;amp;yr Storms";&lt;BR /&gt;   proc means data=mc1.storm_final n min &lt;BR /&gt;                    mean max maxdec=0;&lt;BR /&gt;      var MaxWindMPH MinPressure;&lt;BR /&gt;      where season=&amp;amp;yr;&lt;BR /&gt;   run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend storms;&lt;BR /&gt;%storms(2011 2012 2014);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_1-1741110157644.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105155iAC2FB62E24D41B9F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dxiao2017_1-1741110157644.png" alt="dxiao2017_1-1741110157644.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem here is that although the course is about using macros, this is a problem that doesn't need to be solved by macros, and you would be much better off simply producing the results with PROC MEANS and a BY statement. So it is teaching you to use macros when macros are not needed, in my opinion, this is the wrong lesson to learn. I have said this many times: an important piece of learning to use macros is learning when NOT to use macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example using SASHELP.CARS data set&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars out=cars;
    by origin;
run;
proc means data=cars n min mean max maxdec=0;
    where origin='Asia' or origin='Europe';
    by origin;
    var msrp invoice;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 18:12:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960868#M281</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-03-04T18:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960881#M282</link>
      <description>&lt;P&gt;I am not sure where this appears in their overall instruction plan but I would definitely agree that it is better to learn how to perform a simple iterative %DO loop before trying to learn how to do a complex one where you have to code your own increments and boundary tests.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also I am not sure why they left out the %LOCAL statement that should be there to prevent running this macro from modifying existing macro variables named I or YR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 20:21:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960881#M282</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-03-04T20:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960885#M283</link>
      <description>&lt;P&gt;That shown style of looping over a list with %DO %UNTIL was common prior to the introduction of the COUNTW function.&amp;nbsp; I think COUNTW was introduced in v7 or v8.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would agree that using COUNTW to count the number of items in a list seems clearer to me also.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 20:43:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960885#M283</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2025-03-04T20:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960891#M284</link>
      <description>&lt;P&gt;Agree with others here - I would just add that with COUNTW and SCAN (and similar), it's a good idea to specify your delimiter as the optional last argument - otherwise, SAS will try to guess.&amp;nbsp; And further, if the delimiter is a space (as it is here), never a bad idea to clean up potential multiple whitespace characters with %CMPRES:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let YRLIST=2012 2014 2016;
%let YRLIST=%CMPRES(&amp;amp;YRLIST);
%let nYRS=%sysfunc(countW(&amp;amp;YRLIST,' '));

.... %let YR=%SCAN(&amp;amp;YRLIST, &amp;amp;i, ' ');

* you can also use %STR( ) instead of ' ' above ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 23:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960891#M284</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-03-04T23:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960895#M285</link>
      <description>&lt;P&gt;Thanks a lot for your comments, I think it's a very good point that use macro (or any other advanced and complex procs and steps) only when it is necessary. However, I really do NOT think that question (as well as the solution) in the lesson was poorly designed, as 1) the learning material was to cover a lot of important contents of macro, and it was also designed for test preparation and had to include all the knowledge and techniques in the exam content guide, and therefore 2) while design the material, (I guess) the course developer was intended to integrate as much as possible contents in one question, and this makes the solution code complicated, and 3) besides the macro part of the built-in base 9.4 guide (SAS 9.4 macro language reference), as a new learner I think Macro1:Essential is the good official learning material I can find now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For that question in my post, what made the solution code complex was the &lt;STRONG&gt;&lt;EM&gt;%let i=%eval(&amp;amp;i+1);&lt;/EM&gt; &lt;/STRONG&gt;statement, which now I guess was perhaps exactly what the material developer wanted learners to comprehend (which is not easy, e.g. how the two repeated &lt;EM&gt;%let i=;&lt;/EM&gt; and &lt;EM&gt;%let yr=;&lt;/EM&gt; statements work) , because that statement is used in a lot of scenarios when there is a do loop inside a macro.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Mar 2025 00:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960895#M285</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-03-05T00:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960896#M286</link>
      <description>&lt;P&gt;There are sections and questions about %local statement in the material. In fact, while doing the question I tried to use %local statement inside the macro but did not run through (as using %local statement inside a macro makes the macro a lot more complicated, will try it later).&lt;/P&gt;</description>
      <pubDate>Wed, 05 Mar 2025 01:01:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960896#M286</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-03-05T01:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960901#M287</link>
      <description>&lt;P&gt;Thanks a lot for your comments! I tested your examples and somehow got something like this (see below). I have three questions: 1) it looks like the&lt;EM&gt; %cmpres&lt;/EM&gt; function is not necessary (at least in my example), if I run the &lt;EM&gt;%cmpres&lt;/EM&gt; statement I got error message; 2) if I want to clean up whitespace characters the function to be use is &lt;EM&gt;compbl&lt;/EM&gt; (I do not know how this function is written when it is a macro function), not &lt;EM&gt;compress&lt;/EM&gt;, am I right or wrong? 3) this question is not relevant, how can I make the code posted here colored?&lt;/P&gt;
&lt;P&gt;(after I post THIS message I found it is colored somehow, however, the code in my previous post were not)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let yrlist=%nrstr(2010 % 2012 2014,2016   2018 &amp;amp; 2019);
*%let yrlist=%cmpres(&amp;amp;yrlist,'%,&amp;amp;');
*%put &amp;amp;yrlist;
%let nyrs=%sysfunc(countw(&amp;amp;yrlist,' %,&amp;amp;'));
%put &amp;amp;nyrs;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_0-1741138251243.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105158iB22C489BF25AA1B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="dxiao2017_0-1741138251243.png" alt="dxiao2017_0-1741138251243.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Mar 2025 01:50:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960901#M287</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-03-05T01:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960909#M288</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223320"&gt;@quickbluefish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Agree with others here - I would just add that with COUNTW and SCAN (and similar), it's a good idea to specify your delimiter as the optional last argument - otherwise, SAS will try to guess.&amp;nbsp; And further, if the delimiter is a space (as it is here), never a bad idea to clean up potential multiple whitespace characters with %CMPRES:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let YRLIST=2012 2014 2016;
%let YRLIST=%CMPRES(&amp;amp;YRLIST);
%let nYRS=%sysfunc(countW(&amp;amp;YRLIST,' '));

.... %let YR=%SCAN(&amp;amp;YRLIST, &amp;amp;i, ' ');

* you can also use %STR( ) instead of ' ' above ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I agree it's good practice to specify the delimiter for COUNTW and %SCAN.&amp;nbsp; Particularly because if you have an empty list, %sysfunc(countw()) will throw an error, but&amp;nbsp;%sysfunc(countw(,%str( )))&amp;nbsp; will return 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That said, I think it's much clearer/better to use %STR( ) to specify the blank as delimiter, rather than ' '.&amp;nbsp; If you use ' ' you're telling the macro processor to use both blank and a single quote as delimiters.&amp;nbsp; In the macro language ' ' is a three character string, not a single blank.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Mar 2025 03:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960909#M288</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2025-03-05T03:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960911#M289</link>
      <description>&lt;P&gt;Hi Tom, I have two further questions: 1) could you come up with an example (base on the code in my post) that use %local statement, and 2) explain a bit more on how the %let i=%eval(&amp;amp;i+1); statement work in the code in my post? Many thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Mar 2025 04:26:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960911#M289</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-03-05T04:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960940#M290</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466238"&gt;@dxiao2017&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks a lot for your comments, I think it's a very good point that use macro (or any other advanced and complex procs and steps) only when it is necessary. However, I really do NOT think that question (as well as the solution) in the lesson was poorly designed, as 1) the learning material was to cover a lot of important contents of macro, and it was also designed for test preparation and had to include all the knowledge and techniques in the exam content guide, and therefore 2) while design the material, (I guess) the course developer was intended to integrate as much as possible contents in one question, and this makes the solution code complicated, and 3) besides the macro part of the built-in base 9.4 guide (SAS 9.4 macro language reference), as a new learner I think Macro1:Essential is the good official learning material I can find now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For that question in my post, what made the solution code complex was the &lt;STRONG&gt;&lt;EM&gt;%let i=%eval(&amp;amp;i+1);&lt;/EM&gt; &lt;/STRONG&gt;statement, which now I guess was perhaps exactly what the material developer wanted learners to comprehend (which is not easy, e.g. how the two repeated &lt;EM&gt;%let i=;&lt;/EM&gt; and &lt;EM&gt;%let yr=;&lt;/EM&gt; statements work) , because that statement is used in a lot of scenarios when there is a do loop inside a macro.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A person who takes this macro course then goes out and has a real problem which is similar to the one presented, the person needs means by different years. And the person says "I learned how to do that in my class! I'll write a macro!" And I contend this is the wrong thing to do, and the person has learned the wrong lesson.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I was going to design a macro class, I would not include using macros to replace other built-in tools in SAS. If the developer of the class wants to teach&amp;nbsp;&lt;FONT face="courier new,courier"&gt;%let i=%eval(&amp;amp;i+1);&lt;/FONT&gt; there are plenty of ways to teach this without re-creating a BY statement with macro code.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Mar 2025 14:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960940#M290</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-03-05T14:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960942#M291</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466238"&gt;@dxiao2017&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Tom, I have two further questions: 1) could you come up with an example (base on the code in my post) that use %local statement, and 2) explain a bit more on how the %let i=%eval(&amp;amp;i+1); statement work in the code in my post? Many thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Local statement is very simple.&amp;nbsp; Just list the macro variables that you want defined as local to the macro.&amp;nbsp; In this program that would look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro storms(list);
%local count i yr ;
%let count=%sysfunc(countw(&amp;amp;list,%str( )));
%do i=1 %to &amp;amp;count;
   %let yr=%scan(&amp;amp;list,&amp;amp;i,%str( ));
   title "&amp;amp;yr Storms";
   proc means data=mc1.storm_final n min 
                    mean max maxdec=0
   ;
      where season=&amp;amp;yr;
      var MaxWindMPH MinPressure;
   run;
%end;
%mend storms;
%storms(2011 2012 2014);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To see the impact try running this little program with both versions of the macro.&amp;nbsp; What value does COUNT have at the end?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let count=100;
%storms(2011 2012 2014)
%put &amp;amp;=count;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also try running it both ways when the COUNT macro variables does not exist before the macro runs:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%symdel count ;
%storms(2011 2012 2014)
%put &amp;amp;=count;&lt;/CODE&gt;&lt;/PRE&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;This statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let i=%eval(&amp;amp;i+1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is a simple %LET to assign a value (a new value) to a macro variable.&amp;nbsp; The macro function %EVAL() will evaluate simple integer arithmetic (and boolean) expressions.&amp;nbsp; So &amp;amp;I+1 will convert to something like 1+1 or 2+1 and %EVAL() will then convert that into 2 or 3 and the %LET will store that new digit string into the macro variable I.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Mar 2025 14:19:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/960942#M291</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-03-05T14:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961044#M292</link>
      <description>&lt;P&gt;I agree with you on this point that when writing a macro is not necessary then do not use macro, when a macro is necessary then use macro and do not use other procedures. There is another question (m105a04) in the material on the PDF's page 262, the solution of which was to produce separate tables for different levels (categories) of a variable, and a &lt;EM&gt;cat()&lt;/EM&gt; statement in a sql step was used to split the table (and this serves as the first step of producing separate TFLs for different levels of a variable), the code and output are as follows (BTW: in the demo m105d04 next to the question, the code was indeed developed to a macro, which I tried several times and was not able to run through, perhaps due to the difficulty in debugging (for both the&lt;EM&gt; cat()&lt;/EM&gt; statement and the &lt;EM&gt;case when then;&lt;/EM&gt; statement in the subsequent &lt;EM&gt;data&lt;/EM&gt; step which was intended to produce separate datasets):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let tab=sashelp.cars;
%let col=Origin;
proc sql;
select distinct &amp;amp;col
    from &amp;amp;tab;
select distinct cat('when ("', &amp;amp;col, '") output ', &amp;amp;col) 
    from &amp;amp;tab;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_1-1741253867143.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105198i8D6E6B1D901CB522/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dxiao2017_1-1741253867143.png" alt="dxiao2017_1-1741253867143.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In the above code, the character string in the&lt;EM&gt; cat()&lt;/EM&gt; statement consumes a lot of eyesight and detailed attention to type it. The more important issue is that I think this is a question which can be properly (and more appropriately) solved through a macro (there are other questions and sections for this type of macro in the material though, btw), i.e., a macro here is necessary (BTW, here as I mentioned in last paragraph, I made a mistake here - the code was indeed developed into a macro, yet which possibly may cost a lot debugging) . However, I guess the &lt;EM&gt;cat()&lt;/EM&gt; statement here in the solution code for this question is to let leaners know that some steps in the macro can be replaced by the &lt;EM&gt;cat()&lt;/EM&gt; statement, i.e., a possible usage of the&lt;EM&gt; cat()&lt;/EM&gt;&amp;nbsp;function and cat() statements in a sql step. The macro that I think can properly solve the question and the output are as follows (BTW: the code below&amp;nbsp; was generated according to the solution code on page 286 of the PDF for another question, m105p01, as the reference code, which uses a &lt;EM&gt;proc print;&lt;/EM&gt; step instead of &lt;EM&gt;proc sql; select * from;&lt;/EM&gt;&amp;nbsp;statement). A further step of consideration may be adding in the &lt;EM&gt;create table &amp;amp;xxx as&lt;/EM&gt; to name the different datasets according to their respective categories/levels of that variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro splittable(tab,col);
proc sql;
select distinct &amp;amp;col
   into :cat1-
   from &amp;amp;tab;
quit;
%do i=1 %to &amp;amp;sqlobs;
proc sql outobs=2;
select * 
   from &amp;amp;tab
   where &amp;amp;col="&amp;amp;&amp;amp;cat&amp;amp;i";
quit;
%end;
%mend splittable;
%splittable(sashelp.cars,origin);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_2-1741255222857.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105199iDDC6EC6D4DDE78FA/image-size/large?v=v2&amp;amp;px=999" role="button" title="dxiao2017_2-1741255222857.png" alt="dxiao2017_2-1741255222857.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2025 14:02:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961044#M292</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-03-06T14:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961122#M293</link>
      <description>&lt;P&gt;Hi Tom, thanks a lot for your feedback, but I am not sure I understand your steps correctly or not, below is what I run and the output, there is no difference in this output and the output of that one without the %local statement. For my second question, I think what I asked was: for what scenario the &lt;EM&gt;%let i=%eval(&amp;amp;i+1);&lt;/EM&gt; statement is useful and necessary, because for any list of strings or numbers, we can use &lt;EM&gt;select distinct var into :list;&lt;/EM&gt;&amp;nbsp;and &lt;EM&gt;&amp;amp;sqlobs&lt;/EM&gt; or &lt;EM&gt;call symputx(xxx, yyy);&lt;/EM&gt; or the&lt;EM&gt; countw()&lt;/EM&gt; function to decide how many times the %do loop run.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro storms(list);
%local count i yr;
%let count=%sysfunc(countw(&amp;amp;list));
%do i=1 %to &amp;amp;count;
   %let yr=%scan(&amp;amp;list,&amp;amp;i);
   title "&amp;amp;yr Storms (local count)";
   proc means data=mc1.storm_final n min 
                    mean max maxdec=0;
      var MaxWindMPH MinPressure;
      where season=&amp;amp;yr;
   run;
%end;
%mend storms;
%let count=100;
%storms(2011 2012 2014);
%put &amp;amp;count;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_0-1741280129582.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105239iC26B136173E2287B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dxiao2017_0-1741280129582.png" alt="dxiao2017_0-1741280129582.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_1-1741280255925.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105240iB5839F11A8C0E259/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dxiao2017_1-1741280255925.png" alt="dxiao2017_1-1741280255925.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2025 17:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961122#M293</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-03-06T17:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961125#M294</link>
      <description>&lt;P&gt;As your post showed, when you run:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let count=100;
%storms(2011 2012 2014)
%put &amp;amp;count;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If your macro storms uses the %local statement to create a new local macro variable COUNT, the %PUT statement at the end will show that the global macro variable COUNT still has the value 100.&lt;BR /&gt;&lt;BR /&gt;Now if you remove the %local statement from your macro definition and recompile the macro, then run the same code, the&amp;nbsp; %PUT statement at the end will show that the global macro variable COUNT has a different value.&amp;nbsp; Please try it out.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2025 17:22:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961125#M294</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2025-03-06T17:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961142#M295</link>
      <description>&lt;P&gt;Hi Tom, (I do not know if I understand your comments correctly, it looks like the %local statement is for retaining a macro variable value only for the current use and prevent it from overwriting a previously created macro variable value that has the same macro name, am I right or wrong?) the material did not left out the %local statement and has section and questions for it, I have not get to there yet, because I personally would like to learn write a simple and useful macro (according to what I would like to produce) first, and then learn storing, re-using macros, and etc. alike contents, and thus I omitted the several questions about the %local and %global statements at the moment and will learn it later.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2025 20:04:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961142#M295</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-03-06T20:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961148#M296</link>
      <description>&lt;P&gt;Thanks a lot for your suggestion, I tried some thing like this (see below) after read again in the learning material the section (p174 of the PDF) on %local and %global statements. I tested the code below in windowing (base 9.4) environment (this does not make anything different btw just somehow feel like to mention it for no reason). Will try other examples later.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="localmacro.JPG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105250i6D5539946F0C05F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="localmacro.JPG" alt="localmacro.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2025 20:45:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961148#M296</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-03-06T20:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961150#M297</link>
      <description>&lt;P&gt;You are close.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are right that for&amp;nbsp;this example macro it does not impact how this macro behaves.&amp;nbsp; You demonstrated that in your testing.&amp;nbsp; The macro can still assign values to the macro variables it is using and retrieve the values it has assigned.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where it does make a difference is for the environments (open code or some other running macros) that might call this macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This meaning of LOCAL is different than what you will find in most other computer languages that allow local variables.&amp;nbsp; In those languages LOCAL is meant to protect your variables from being seen and/or modified by other programs.&amp;nbsp; But in the SAS macro processor language you use LOCAL macro variables to prevent your program (the currently running macro) from modifying macro variables defined by other macros (or global macro variables).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The %LOCAL statement will create a macro variable in the symbol table of the current macro (if one already exists then it does nothing).&amp;nbsp; Which symbol table the macro is in determines its "scope".&amp;nbsp; You can see all macro variables that exist in the scope of macros that have called the current macro.&amp;nbsp; Except when they are hidden by macro variables with the same name in a "lower" scope (that is closer to the scope of the currently executing macro).&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also modify those macro variables that live (AKA are defined&amp;nbsp; in; AKA&amp;nbsp; LOCAL to) macros that have called you and global macros.&amp;nbsp; The exception being some system/automatic macro variables that are readonly.&amp;nbsp; And recently SAS added syntax that make it is possible for users to define readonly global macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you reference a macro variable using &lt;FONT face="courier new,courier"&gt;&amp;amp;mvarname&lt;/FONT&gt;&amp;nbsp; SAS will use the macro variable it finds in the lowest scope.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you &amp;nbsp;assign a value to a macro variable using &lt;FONT face="courier new,courier"&gt;%LET mvarname=&lt;/FONT&gt; SAS will use an existing macro variable before making a new one. When it does make a new one it is make&amp;nbsp; in the current scope.&amp;nbsp; Note actually when the current macro has not defined any macro variables then CALL SYMPUT() will create new macro variables in the lowest scope that does have macro variables.&amp;nbsp; See discussion in CALL SYMPUT() documentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that parameters that the macro accepts (defined in the %MACRO statement) are always defined as LOCAL macro variables in the macro's scope.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you really want to find the value of macro variable that has been blocked/hidden by a macro variable with the same name at a lower scope you can use this macro:&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/symget.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/symget.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2025 20:55:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961150#M297</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-03-06T20:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961159#M298</link>
      <description>&lt;P&gt;Your example shows that calling TEST1 did NOT change the value of X defined in the global symbol table.&amp;nbsp; Note that there was not need to wrap the %PUT inside of the macro named TEST2 to show this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now make a new version of TEST1 (or make a TEST3) that does NOT include the %LOCAL statement and see what value X has after you call that new macro.&amp;nbsp; It should be 2 instead of the 1 you set it to at the top.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2025 21:05:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961159#M298</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-03-06T21:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Another way(and simpler) to solve practice question m104p11 on page 224 ,Macro1: Essentials pdf</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961307#M299</link>
      <description>&lt;P&gt;Is this (see below) what you and Tom want me to try? Without the %local statement: got a warning message (&amp;amp;count cannot resolve) and something massed up with the report title(the 2011 one becomes 2014, which is not correct):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro storms(list);
*%local count i yr;
%let count=%sysfunc(countw(&amp;amp;list));
%do i=1 %to &amp;amp;count;
   %let yr=%scan(&amp;amp;list,&amp;amp;i);
   title "&amp;amp;yr Storms";
   proc means data=mc1.storm_final n min 
                    mean max maxdec=0;
      var MaxWindMPH MinPressure;
      where season=&amp;amp;yr;
   run;
%end;
%mend storms;
%storms(2011 2012 2014);

%let count=100;
%storms(2011 2012 2014);
%put &amp;amp;count;

%symdel count;
%storms(2011 2012 2014);
%put &amp;amp;count;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_0-1741448457630.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105283i0D5B30AF985B49BE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dxiao2017_0-1741448457630.png" alt="dxiao2017_0-1741448457630.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_1-1741448589646.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105284iE1847A4DA717BCA7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dxiao2017_1-1741448589646.png" alt="dxiao2017_1-1741448589646.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_2-1741448710780.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105285i5F8CB39ED9F9E8EF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dxiao2017_2-1741448710780.png" alt="dxiao2017_2-1741448710780.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_3-1741448808311.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105286i4F6A60DB0967D481/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dxiao2017_3-1741448808311.png" alt="dxiao2017_3-1741448808311.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_4-1741449194442.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105287i265F687FE6C94E55/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dxiao2017_4-1741449194442.png" alt="dxiao2017_4-1741449194442.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Mar 2025 15:56:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Another-way-and-simpler-to-solve-practice-question-m104p11-on/m-p/961307#M299</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-03-08T15:56:58Z</dc:date>
    </item>
  </channel>
</rss>

