<?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: count the number of &amp;quot;&amp;amp;&amp;quot; in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/519029#M3708</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think a use case can be made, at least for three ampersands.&amp;nbsp; Let's say you have a sequence of links that loop back to the starting node:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let a=b; %let b=c; %let c=d; %let d=a;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're told to start at a, and then advance 6 links, you could do this (or start at detroit and make six steps through the circuit in the code below);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro t(start=,nsteps=);
  %let a=b;               %let b=c;                 %let c=d;               %let d=a;
  %let detroit=ann_arbor; %let ann_arbor=kalamazoo; %let kalamazoo=lansing; %let lansing=detroit;
  %let x=&amp;amp;start;
  %put **** START: &amp;amp;=x;
  %do i=1 %to &amp;amp;nsteps;
    %let x=&amp;amp;&amp;amp;&amp;amp;x;
  %end;
  %put END: &amp;amp;=nsteps &amp;amp;=x;
%mend;

%t(start=a,nsteps=6)&lt;BR /&gt;
%t(start=detroit,nsteps=6)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now the above makes 6 &lt;EM&gt;&lt;STRONG&gt;single-unit&lt;/STRONG&gt;&lt;/EM&gt; steps. And the user doesn't need to know how many links are in a circuit.&amp;nbsp; Now, it''s a bit far-fetched, but I suppose one could conceive of performing some number of 2-unit steps (7&amp;amp;), or&amp;nbsp; 3-unit steps (15&amp;amp; !!!), etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree there is almost always a better way than over 3 ampersands, but I can imagine a three-&amp;amp; code being effective and appropriate.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Dec 2018 06:39:28 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2018-12-06T06:39:28Z</dc:date>
    <item>
      <title>count the number of "&amp;"</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518775#M3617</link>
      <description>&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;%let a=b;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;%let b=c;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;%let c=d;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;%let d=a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;%put &amp;amp;a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;&lt;SPAN&gt;b&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;&lt;SPAN&gt;%put&amp;nbsp;&lt;/SPAN&gt;&amp;amp;&amp;amp;&amp;amp;a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;c&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;d&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;&lt;SPAN&gt;%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;a;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;&lt;SPAN&gt;a&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;&lt;SPAN&gt;I want to count the number of "&amp;amp;" without hard cording by adding the "&amp;amp;"&amp;nbsp;each of the time until i get the answer,&amp;nbsp;like b=1, c=3, d=7, a=15&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 13:19:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518775#M3617</guid>
      <dc:creator>12346</dc:creator>
      <dc:date>2018-12-05T13:19:05Z</dc:date>
    </item>
    <item>
      <title>Count the number of ampersands</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518736#M3803</link>
      <description>&lt;DIV class="textLayer--absolute"&gt;%let a=b;&lt;/DIV&gt;&lt;DIV class="textLayer--absolute"&gt;&lt;SPAN&gt;%let b=c;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="textLayer--absolute"&gt;&lt;SPAN&gt;%let c=d;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="textLayer--absolute"&gt;&lt;SPAN&gt;%let d=a;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="textLayer--absolute"&gt;How to write a macro program to count the number of&amp;nbsp;ampersands is needed for generating the specified result.&lt;/DIV&gt;</description>
      <pubDate>Wed, 05 Dec 2018 11:15:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518736#M3803</guid>
      <dc:creator>12346</dc:creator>
      <dc:date>2018-12-05T11:15:16Z</dc:date>
    </item>
    <item>
      <title>Re: Count the number of ampersands</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518747#M3804</link>
      <description>&lt;P&gt;What "&lt;SPAN&gt;specified result"?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 11:54:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518747#M3804</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-05T11:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: Count the number of ampersands</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518753#M3805</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/250033"&gt;@12346&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;DIV class="textLayer--absolute"&gt;%let a=b;&lt;/DIV&gt;
&lt;DIV class="textLayer--absolute"&gt;&lt;SPAN&gt;%let b=c;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class="textLayer--absolute"&gt;&lt;SPAN&gt;%let c=d;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class="textLayer--absolute"&gt;&lt;SPAN&gt;%let d=a;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class="textLayer--absolute"&gt;How to write a macro program to count the number of&amp;nbsp;ampersands is needed for generating the specified result.&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I do not see a single ampersand in your post, so there's nothing to count.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 12:07:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518753#M3805</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-05T12:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: count the number of "&amp;"</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518777#M3618</link>
      <description>&lt;P&gt;Is there a question or are you just showing how it works?&lt;/P&gt;
&lt;P&gt;You need to add two &amp;amp; to have that resolved to one &amp;amp; and cause macro processor to rescan the string.&lt;/P&gt;
&lt;P&gt;So to get the value of mvar you need one.&lt;/P&gt;
&lt;P&gt;To get the value of mvar named by the mvar you need one + two = three.&lt;/P&gt;
&lt;P&gt;So for the number of &amp;amp; needed to get more and more levels of re-direction&amp;nbsp;you basically have a geometric progression.&amp;nbsp; 2**N + 1.&amp;nbsp; for N=0,1,2,3,....&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 13:35:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518777#M3618</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-12-05T13:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: count the number of "&amp;"</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518788#M3623</link>
      <description>&lt;P&gt;Why?&amp;nbsp; Simply put, if you have more than one &amp;amp; or % on one line of code, then 100% there is a better way of doing things, and the code in question is messy and un-maintainable.&amp;nbsp; The code you present for example is (noting of course how I follow good pramming standards and place the dot after the macro variable name!):&lt;/P&gt;
&lt;PRE&gt;%let a=a;

%put &amp;amp;a.;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 14:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518788#M3623</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-05T14:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: count the number of "&amp;"</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518826#M3637</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; May i request a moment of your time to help me understand how this works. For some reason i never understood indirect referencing with more than 2 ampersands. I would appreciate if you could lend me your time. Plz and thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let a=b;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let b=c;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let c=d;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let d=a;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%put &amp;amp;a;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;b&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;%put&amp;nbsp;&amp;amp;&amp;amp;&amp;amp;a;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;c&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;a;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;d&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;a;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;a&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 15:04:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518826#M3637</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-05T15:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: count the number of "&amp;"</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518846#M3646</link>
      <description>&lt;P&gt;Just run it with the SYMBOLGEN option turned on and the SAS log will explain.&lt;/P&gt;
&lt;P&gt;For example let's take the case of three &amp;amp; .&lt;/P&gt;
&lt;P&gt;So on first pass &amp;amp;&amp;amp; goes to &amp;amp; and &amp;amp;a goes to b.&amp;nbsp; So you now have &amp;amp;b.&amp;nbsp; Which evaluates to c.&lt;/P&gt;
&lt;P&gt;With 5 &amp;amp; you will have three passes.&amp;nbsp; So the first six &amp;amp; get reduced to 3 &amp;amp; and &amp;amp;a goes to B.&amp;nbsp; So now you are back to case with three &amp;amp;.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 15:58:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518846#M3646</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-12-05T15:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: count the number of "&amp;"</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518855#M3651</link>
      <description>&lt;P&gt;Thank you Sir!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 16:29:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/518855#M3651</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-05T16:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: count the number of "&amp;"</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/519029#M3708</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think a use case can be made, at least for three ampersands.&amp;nbsp; Let's say you have a sequence of links that loop back to the starting node:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let a=b; %let b=c; %let c=d; %let d=a;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're told to start at a, and then advance 6 links, you could do this (or start at detroit and make six steps through the circuit in the code below);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro t(start=,nsteps=);
  %let a=b;               %let b=c;                 %let c=d;               %let d=a;
  %let detroit=ann_arbor; %let ann_arbor=kalamazoo; %let kalamazoo=lansing; %let lansing=detroit;
  %let x=&amp;amp;start;
  %put **** START: &amp;amp;=x;
  %do i=1 %to &amp;amp;nsteps;
    %let x=&amp;amp;&amp;amp;&amp;amp;x;
  %end;
  %put END: &amp;amp;=nsteps &amp;amp;=x;
%mend;

%t(start=a,nsteps=6)&lt;BR /&gt;
%t(start=detroit,nsteps=6)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now the above makes 6 &lt;EM&gt;&lt;STRONG&gt;single-unit&lt;/STRONG&gt;&lt;/EM&gt; steps. And the user doesn't need to know how many links are in a circuit.&amp;nbsp; Now, it''s a bit far-fetched, but I suppose one could conceive of performing some number of 2-unit steps (7&amp;amp;), or&amp;nbsp; 3-unit steps (15&amp;amp; !!!), etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree there is almost always a better way than over 3 ampersands, but I can imagine a three-&amp;amp; code being effective and appropriate.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 06:39:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/519029#M3708</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-12-06T06:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: count the number of "&amp;"</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/519367#M3780</link>
      <description>Thanksss!! But can I put x=c then show the result nsteps=6?</description>
      <pubDate>Fri, 07 Dec 2018 05:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/519367#M3780</guid>
      <dc:creator>12346</dc:creator>
      <dc:date>2018-12-07T05:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: count the number of "&amp;"</title>
      <link>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/519397#M3784</link>
      <description>&lt;P&gt;I don't see how you could determine NSTEPS=6 when you would already be&amp;nbsp; at the same destination with NSTEPS=2 in this example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But think about this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; %let source=A;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %let sink=B;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So why not&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; %let X=&amp;amp;source.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Then do a loop and count the number of iterations until macrovar X = macrovar sink.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 12:58:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/count-the-number-of-quot-amp-quot/m-p/519397#M3784</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-12-07T12:58:56Z</dc:date>
    </item>
  </channel>
</rss>

