<?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 SAS DO Loop with values and symbols in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-DO-Loop-with-values-and-symbols/m-p/451215#M113720</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm running a DO LOOP but SAS keeps deleting two observations that I need to keep in my results.&amp;nbsp; For example, this is my dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;RACF&amp;nbsp;&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;U&gt;GROUPS&lt;/U&gt;&lt;/P&gt;&lt;P&gt;USDISEF&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MKZ;admin;FF&lt;/P&gt;&lt;P&gt;EOR_E47 ACCT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%&lt;/P&gt;&lt;P&gt;USI43_SK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;RETSIPX;dba&lt;/P&gt;&lt;P&gt;UT_ACCT C47&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let folder = work.IMG;&lt;BR /&gt;%let loop = GROUPS;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*STEP 1 - Creates DO Loop necessary for possible combined columns in complex files.*/&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data Do_&amp;amp;appname;&lt;BR /&gt;set &amp;amp;folder;&lt;/P&gt;&lt;P&gt;x = countw(&amp;amp;loop);&lt;BR /&gt;do i = 1 to x;&lt;BR /&gt;&amp;amp;loop.1 = scan(&amp;amp;loop, i, ";");&lt;BR /&gt;output;&lt;BR /&gt;END;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the results as needed with the exception of&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;EOR_&lt;/SPAN&gt;&lt;SPAN&gt;E&lt;/SPAN&gt;&lt;SPAN&gt;47 ACCT&amp;nbsp; and&amp;nbsp; &amp;nbsp;UT_ACCT C47&amp;nbsp; .&amp;nbsp; SAS excludes these from the results.&amp;nbsp; How can I get them included with a value of "%"?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any help is much appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Apr 2018 17:31:49 GMT</pubDate>
    <dc:creator>belboy</dc:creator>
    <dc:date>2018-04-04T17:31:49Z</dc:date>
    <item>
      <title>SAS DO Loop with values and symbols</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DO-Loop-with-values-and-symbols/m-p/451215#M113720</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm running a DO LOOP but SAS keeps deleting two observations that I need to keep in my results.&amp;nbsp; For example, this is my dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;RACF&amp;nbsp;&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;U&gt;GROUPS&lt;/U&gt;&lt;/P&gt;&lt;P&gt;USDISEF&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MKZ;admin;FF&lt;/P&gt;&lt;P&gt;EOR_E47 ACCT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%&lt;/P&gt;&lt;P&gt;USI43_SK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;RETSIPX;dba&lt;/P&gt;&lt;P&gt;UT_ACCT C47&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let folder = work.IMG;&lt;BR /&gt;%let loop = GROUPS;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*STEP 1 - Creates DO Loop necessary for possible combined columns in complex files.*/&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data Do_&amp;amp;appname;&lt;BR /&gt;set &amp;amp;folder;&lt;/P&gt;&lt;P&gt;x = countw(&amp;amp;loop);&lt;BR /&gt;do i = 1 to x;&lt;BR /&gt;&amp;amp;loop.1 = scan(&amp;amp;loop, i, ";");&lt;BR /&gt;output;&lt;BR /&gt;END;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the results as needed with the exception of&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;EOR_&lt;/SPAN&gt;&lt;SPAN&gt;E&lt;/SPAN&gt;&lt;SPAN&gt;47 ACCT&amp;nbsp; and&amp;nbsp; &amp;nbsp;UT_ACCT C47&amp;nbsp; .&amp;nbsp; SAS excludes these from the results.&amp;nbsp; How can I get them included with a value of "%"?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any help is much appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 17:31:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DO-Loop-with-values-and-symbols/m-p/451215#M113720</guid>
      <dc:creator>belboy</dc:creator>
      <dc:date>2018-04-04T17:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DO Loop with values and symbols</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DO-Loop-with-values-and-symbols/m-p/451218#M113722</link>
      <description>&lt;P&gt;What do you mean excludes them from the results? What are you getting, versus, what do you expect?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 17:40:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DO-Loop-with-values-and-symbols/m-p/451218#M113722</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-04T17:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DO Loop with values and symbols</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DO-Loop-with-values-and-symbols/m-p/451225#M113724</link>
      <description>&lt;P&gt;First I think you need to describe a bit more of what this is supposed to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue is documented in the documentation for the Countw function of "what is a word":&lt;/P&gt;
&lt;PRE&gt;"word" refers to a substring that has one of the following characteristics: 
• is bounded on the left by a delimiter or the beginning of the string 
 
•is bounded on the right by a delimiter or the end of the string 
 
•contains no delimiters, except if you use the Q modifier and the delimiters are within substrings that have quotation marks 
&lt;/PRE&gt;
&lt;P&gt;The last one is the cause of your problem as delimiters for countw are:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;If your computer uses ASCII characters, then the default delimiters are as follows: 
 
blank ! $ % &amp;amp; ( ) * + , - . / ; &amp;lt; ^ | &lt;/PRE&gt;
&lt;P&gt;So since your value is % that is a delimiter and countw("%",1) returns 0. And the do loop becomes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do I = 1 to 0; so it never actually loops.&lt;/P&gt;
&lt;P&gt;Since that, hopefully, would be a special case you could use something like&lt;/P&gt;
&lt;PRE&gt;data Do_&amp;amp;appname;
   set &amp;amp;folder;
   x = countw(&amp;amp;loop);
   if x&amp;gt;0 then    do i = 1 to x;
   &amp;amp;loop.1 = scan(&amp;amp;loop, i, ";");
      output;
   END;
   else do;
      &amp;amp;loop.1=&amp;amp;loop;
      output;
   end;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Apr 2018 17:53:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DO-Loop-with-values-and-symbols/m-p/451225#M113724</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-04T17:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: SAS DO Loop with values and symbols</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-DO-Loop-with-values-and-symbols/m-p/451240#M113728</link>
      <description>&lt;P&gt;THanks!!&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 18:27:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-DO-Loop-with-values-and-symbols/m-p/451240#M113728</guid>
      <dc:creator>belboy</dc:creator>
      <dc:date>2018-04-04T18:27:38Z</dc:date>
    </item>
  </channel>
</rss>

