<?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: Do loops in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/888920#M351175</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446448"&gt;@112211&lt;/a&gt;,&amp;nbsp;I didn't see your desired output until now.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop = i);
length a_want $50.; /* Needs to be set depending on output */
a = "United States of America";
do i = countw(a, " ") to 1 by -1;
a_want = catx(" ", a_want, scan(a, i, " "));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Basically, your loop starts at 4 because COUNTW finds four words. I use the by -1 to go from 4 --&amp;gt; 3 --&amp;gt; 2 -- 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CATX then combines each word with the DO loop.&lt;/P&gt;</description>
    <pubDate>Fri, 11 Aug 2023 11:42:32 GMT</pubDate>
    <dc:creator>maguiremq</dc:creator>
    <dc:date>2023-08-11T11:42:32Z</dc:date>
    <item>
      <title>Do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/888908#M351170</link>
      <description>Data do;&lt;BR /&gt;A= 'United States of America ';&lt;BR /&gt;Run ;&lt;BR /&gt;&lt;BR /&gt;I need output like reverse words below mentioned (preferably use do loops &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;America of states united</description>
      <pubDate>Fri, 11 Aug 2023 10:19:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/888908#M351170</guid>
      <dc:creator>112211</dc:creator>
      <dc:date>2023-08-11T10:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: Do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/888909#M351171</link>
      <description>&lt;P&gt;Use the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/n0r87nwd0lt2rzn1h348larywe0r.htm" target="_self"&gt;REVERSE function&lt;/A&gt;, no loops needed&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
&amp;nbsp; &amp;nbsp; set do;
&amp;nbsp; &amp;nbsp; reverse_A=reverse(A);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2023 10:51:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/888909#M351171</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-11T10:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: Do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/888920#M351175</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446448"&gt;@112211&lt;/a&gt;,&amp;nbsp;I didn't see your desired output until now.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop = i);
length a_want $50.; /* Needs to be set depending on output */
a = "United States of America";
do i = countw(a, " ") to 1 by -1;
a_want = catx(" ", a_want, scan(a, i, " "));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Basically, your loop starts at 4 because COUNTW finds four words. I use the by -1 to go from 4 --&amp;gt; 3 --&amp;gt; 2 -- 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CATX then combines each word with the DO loop.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2023 11:42:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/888920#M351175</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2023-08-11T11:42:32Z</dc:date>
    </item>
  </channel>
</rss>

