<?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 for help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/for-help/m-p/68972#M14967</link>
    <description>&lt;B&gt; I am trying to run the code following, but it keeps running infinitely. Can somebody figure out what is wrong with it, please? Thanks&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
libname learn 'F:\SPH project\alcohol task';&lt;BR /&gt;
options mprint mlogic;&lt;BR /&gt;
&lt;BR /&gt;
%macro etoh_category(type);&lt;BR /&gt;
     data socialhis_&amp;amp;type(drop=i);&lt;BR /&gt;
        set learn.socialhis;&lt;BR /&gt;
        length etoh $ 10;&lt;BR /&gt;
	 %let i=%eval(1);&lt;BR /&gt;
	 %do %while ("%scan(%nrbquote(&amp;amp;&amp;amp;&amp;amp;type),&amp;amp;i,'*')" ne ' ');&lt;BR /&gt;
                 if index(compress(upcase(social_history)),trim("%scan(%nrbquote(&amp;amp;&amp;amp;&amp;amp;type),&amp;amp;i,'*')")) then etoh="&amp;amp;type";&lt;BR /&gt;
	  %let i=%eval(&amp;amp;i+1);&lt;BR /&gt;
                  %end;&lt;BR /&gt;
	 run;&lt;BR /&gt;
	%mend;&lt;BR /&gt;
	&lt;BR /&gt;
     %etoh_category(none)</description>
    <pubDate>Wed, 02 Sep 2009 15:44:14 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-09-02T15:44:14Z</dc:date>
    <item>
      <title>for help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/for-help/m-p/68972#M14967</link>
      <description>&lt;B&gt; I am trying to run the code following, but it keeps running infinitely. Can somebody figure out what is wrong with it, please? Thanks&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
libname learn 'F:\SPH project\alcohol task';&lt;BR /&gt;
options mprint mlogic;&lt;BR /&gt;
&lt;BR /&gt;
%macro etoh_category(type);&lt;BR /&gt;
     data socialhis_&amp;amp;type(drop=i);&lt;BR /&gt;
        set learn.socialhis;&lt;BR /&gt;
        length etoh $ 10;&lt;BR /&gt;
	 %let i=%eval(1);&lt;BR /&gt;
	 %do %while ("%scan(%nrbquote(&amp;amp;&amp;amp;&amp;amp;type),&amp;amp;i,'*')" ne ' ');&lt;BR /&gt;
                 if index(compress(upcase(social_history)),trim("%scan(%nrbquote(&amp;amp;&amp;amp;&amp;amp;type),&amp;amp;i,'*')")) then etoh="&amp;amp;type";&lt;BR /&gt;
	  %let i=%eval(&amp;amp;i+1);&lt;BR /&gt;
                  %end;&lt;BR /&gt;
	 run;&lt;BR /&gt;
	%mend;&lt;BR /&gt;
	&lt;BR /&gt;
     %etoh_category(none)</description>
      <pubDate>Wed, 02 Sep 2009 15:44:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/for-help/m-p/68972#M14967</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-09-02T15:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: for help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/for-help/m-p/68973#M14968</link>
      <description>If it is running infinitely and not ever stopping that means that the right side of this statement:&lt;BR /&gt;
&lt;BR /&gt;
%do %while ("%scan(%nrbquote(&amp;amp;&amp;amp;&amp;amp;type),&amp;amp;i,'*')" ne ' ');&lt;BR /&gt;
&lt;BR /&gt;
is never being met ... the NE ' '.  Not having seen your data, whatever &amp;amp;&amp;amp;&amp;amp;type resolves to be is not ever returning an actual value.   I think the reason is that what is in the ( ) is not actually resolving due to the double quotes around the %scan() function.   So it is seeing the text "%scan(%nrbquote(&amp;amp;&amp;amp;&amp;amp;type),&amp;amp;i,'*')"  as not equal to '' and never ending the loop.&lt;BR /&gt;
&lt;BR /&gt;
Try removing the double quotes in both places and see if that makes a difference.  If you need the value quoted, you can try adding:&lt;BR /&gt;
&lt;BR /&gt;
%let myval = "%scan(%nrbquote(&amp;amp;&amp;amp;&amp;amp;type),&amp;amp;i,'*';&lt;BR /&gt;
&lt;BR /&gt;
after the do while and then use "&amp;amp;myval" in your index() function instead of running the %scan again.&lt;BR /&gt;
&lt;BR /&gt;
Daniel</description>
      <pubDate>Wed, 02 Sep 2009 16:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/for-help/m-p/68973#M14968</guid>
      <dc:creator>daveryBBW</dc:creator>
      <dc:date>2009-09-02T16:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: for help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/for-help/m-p/68974#M14969</link>
      <description>The code, as shown, is generating a SAS warning:&lt;BR /&gt;
&lt;BR /&gt;
WARNING: Apparent symbolic reference NONE not resolved&lt;BR /&gt;
&lt;BR /&gt;
You need to define this macro variable for whatever purpose it has in your macro execution.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 02 Sep 2009 16:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/for-help/m-p/68974#M14969</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-09-02T16:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: for help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/for-help/m-p/68975#M14970</link>
      <description>Does &amp;amp;none have an assignment elsewhere? (as Scott pointed out &amp;amp;&amp;amp;&amp;amp;type resolves on first pass to &amp;amp;none then &amp;amp;none is not assigned)  If not change:&lt;BR /&gt;
%do %while ("%scan(%nrbquote(&amp;amp;&amp;amp;&amp;amp;type),&amp;amp;i,'*')" ne ' ');&lt;BR /&gt;
to %do %while ("%scan(%nrbquote(&amp;amp;type),%eval(&amp;amp;i),'*')" ne "");&lt;BR /&gt;
 &lt;BR /&gt;
&amp;amp;i needs some help getting out and you had a space between single quotes which to a macro comparison is not the same as two double quotes without a space.  This will stop the looping.&lt;BR /&gt;
&lt;BR /&gt;
Now you will need to examine the rest of the macro since there are problems there as well.&lt;BR /&gt;
&lt;BR /&gt;
A few more notes: try using symget(type) to bring the macro var into your data step.  Also  if type is a string which can be parsed on  '*' as indicated it will not work as part of the dataset name.</description>
      <pubDate>Wed, 02 Sep 2009 18:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/for-help/m-p/68975#M14970</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2009-09-02T18:20:43Z</dc:date>
    </item>
  </channel>
</rss>

