<?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 Variable not entering macro properly in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-entering-macro-properly/m-p/10691#M897</link>
    <description>I have the following code:&lt;BR /&gt;
&lt;BR /&gt;
%macro groupthem(a,grpmin,grpmax);&lt;BR /&gt;
    data testr;&lt;BR /&gt;
      set test;&lt;BR /&gt;
	  amt_grp&amp;amp;a=0;&lt;BR /&gt;
	  %do i=1 %to rval;&lt;BR /&gt;
&lt;BR /&gt;
      %do %until (amt_grp&amp;amp;a eq 1);&lt;BR /&gt;
         &lt;BR /&gt;
	    %if %sysevalf((&amp;amp;grpmin)&amp;lt;=(amt_min/1000)&amp;lt;(&amp;amp;grpmax)) %then&lt;BR /&gt;
		amt_grp&amp;amp;a=1; &lt;BR /&gt;
	    %end; &lt;BR /&gt;
     %end; &lt;BR /&gt;
     &lt;BR /&gt;
  run;&lt;BR /&gt;
&lt;BR /&gt;
	%mend;&lt;BR /&gt;
&lt;BR /&gt;
%groupthem(1,10,24.99999);&lt;BR /&gt;
&lt;BR /&gt;
I have a couple of issues here, I want to use rval as the upper limit of iterations of the do loop. rval is defined for each obs in a prior data step, it is an integer.&lt;BR /&gt;
I want the if statement to evaluate the value of amt_min, which is numeric. If the condition is true I want to change the value of amt_grp to 1 and exit the do loop. The amt_grp=1 will be used later to identify obs that fit into said group....&lt;BR /&gt;
&lt;BR /&gt;
I repeatedly get an error stating the %eval function encountered a character when expecting a numeric. I cannot get macro to exit the loop properly nor can I get the rval, or upper bound to be recognized by sas. suggestions?</description>
    <pubDate>Mon, 02 Nov 2009 16:51:01 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-11-02T16:51:01Z</dc:date>
    <item>
      <title>Variable not entering macro properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-entering-macro-properly/m-p/10691#M897</link>
      <description>I have the following code:&lt;BR /&gt;
&lt;BR /&gt;
%macro groupthem(a,grpmin,grpmax);&lt;BR /&gt;
    data testr;&lt;BR /&gt;
      set test;&lt;BR /&gt;
	  amt_grp&amp;amp;a=0;&lt;BR /&gt;
	  %do i=1 %to rval;&lt;BR /&gt;
&lt;BR /&gt;
      %do %until (amt_grp&amp;amp;a eq 1);&lt;BR /&gt;
         &lt;BR /&gt;
	    %if %sysevalf((&amp;amp;grpmin)&amp;lt;=(amt_min/1000)&amp;lt;(&amp;amp;grpmax)) %then&lt;BR /&gt;
		amt_grp&amp;amp;a=1; &lt;BR /&gt;
	    %end; &lt;BR /&gt;
     %end; &lt;BR /&gt;
     &lt;BR /&gt;
  run;&lt;BR /&gt;
&lt;BR /&gt;
	%mend;&lt;BR /&gt;
&lt;BR /&gt;
%groupthem(1,10,24.99999);&lt;BR /&gt;
&lt;BR /&gt;
I have a couple of issues here, I want to use rval as the upper limit of iterations of the do loop. rval is defined for each obs in a prior data step, it is an integer.&lt;BR /&gt;
I want the if statement to evaluate the value of amt_min, which is numeric. If the condition is true I want to change the value of amt_grp to 1 and exit the do loop. The amt_grp=1 will be used later to identify obs that fit into said group....&lt;BR /&gt;
&lt;BR /&gt;
I repeatedly get an error stating the %eval function encountered a character when expecting a numeric. I cannot get macro to exit the loop properly nor can I get the rval, or upper bound to be recognized by sas. suggestions?</description>
      <pubDate>Mon, 02 Nov 2009 16:51:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-not-entering-macro-properly/m-p/10691#M897</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-11-02T16:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Variable not entering macro properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-entering-macro-properly/m-p/10692#M898</link>
      <description>&amp;gt; I have the following code:&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; %macro groupthem(a,grpmin,grpmax);&lt;BR /&gt;
&amp;gt;     data testr;&lt;BR /&gt;
&amp;gt;   set test;&lt;BR /&gt;
&amp;gt;  amt_grp&amp;amp;a=0;&lt;BR /&gt;
&amp;gt;   %do i=1 %to rval;&lt;BR /&gt;
&amp;gt;       %do %until (amt_grp&amp;amp;a eq 1);&lt;BR /&gt;
&amp;gt;    &lt;BR /&gt;
&amp;gt; %if %sysevalf((&amp;amp;grpmin)&amp;lt;=(amt_min/1000)&amp;lt;(&amp;amp;grpmax))&lt;BR /&gt;
&amp;gt;  %then&lt;BR /&gt;
&amp;gt; 	amt_grp&amp;amp;a=1; &lt;BR /&gt;
&amp;gt; 	    %end; &lt;BR /&gt;
&amp;gt;      %end; &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt;   run;&lt;BR /&gt;
&amp;gt; 	%mend;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; %groupthem(1,10,24.99999);&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; I have a couple of issues here, I want to use rval as&lt;BR /&gt;
&amp;gt; the upper limit of iterations of the do loop. rval is&lt;BR /&gt;
&amp;gt; defined for each obs in a prior data step, it is an&lt;BR /&gt;
&amp;gt; integer.&lt;BR /&gt;
&amp;gt; I want the if statement to evaluate the value of&lt;BR /&gt;
&amp;gt; amt_min, which is numeric. If the condition is true I&lt;BR /&gt;
&amp;gt; want to change the value of amt_grp to 1 and exit the&lt;BR /&gt;
&amp;gt; do loop. The amt_grp=1 will be used later to identify&lt;BR /&gt;
&amp;gt; obs that fit into said group....&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; I repeatedly get an error stating the %eval function&lt;BR /&gt;
&amp;gt; encountered a character when expecting a numeric. I&lt;BR /&gt;
&amp;gt; cannot get macro to exit the loop properly nor can I&lt;BR /&gt;
&amp;gt; get the rval, or upper bound to be recognized by sas.&lt;BR /&gt;
&amp;gt; suggestions?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
not sure entire thread posted the first time.</description>
      <pubDate>Mon, 02 Nov 2009 16:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-not-entering-macro-properly/m-p/10692#M898</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-11-02T16:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: Variable not entering macro properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-entering-macro-properly/m-p/10693#M899</link>
      <description>I modified the code slightly and the macro is now properly reading the amtmin value...I'm getting an error wrt to if then condition for the do loop iteration. This amt_grp&amp;amp;a=1 is not working as it should.&lt;BR /&gt;
&lt;BR /&gt;
%macro groupthem(a,grpmin,grpmax);&lt;BR /&gt;
  	data testr;&lt;BR /&gt;
                set test;	  &lt;BR /&gt;
                  amt_grp&amp;amp;a=0;&lt;BR /&gt;
	  %do i=1 %to &amp;amp;rvalu; &lt;BR /&gt;
                       %do %until (amt_grp&amp;amp;a eq 1);&lt;BR /&gt;
         &lt;BR /&gt;
	    %if %sysevalf((&amp;amp;grpmin)&amp;lt;=(&amp;amp;amtmin/1000)&amp;lt;(&amp;amp;grpmax)) %then&lt;BR /&gt;
		amt_grp&amp;amp;a=1;  &lt;BR /&gt;
	    %end; &lt;BR /&gt;
     %end; &lt;BR /&gt;
     &lt;BR /&gt;
  run;&lt;BR /&gt;
&lt;BR /&gt;
	%mend;&lt;BR /&gt;
&lt;BR /&gt;
%groupthem(1,10,24.99999);</description>
      <pubDate>Mon, 02 Nov 2009 17:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-not-entering-macro-properly/m-p/10693#M899</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-11-02T17:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Variable not entering macro properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-entering-macro-properly/m-p/10694#M900</link>
      <description>With the statement below, you are incorrectly mixing SAS macro language code and SAS Data step code:&lt;BR /&gt;
&lt;BR /&gt;
%do %until (amt_grp&amp;amp;a eq 1);&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
As constructured, the two will not function properly.&lt;BR /&gt;
&lt;BR /&gt;
Suggested reading would be SAS DOC on macro language which is generated at compile time versus data step language / code.&lt;BR /&gt;
&lt;BR /&gt;
Also, you would see the most information by adding these statements at the start of your program:&lt;BR /&gt;
&lt;BR /&gt;
OPTIONS SOURCE SOURCE2 MACROGEN SYMBOLGEN MLOGIC NOMPRINT;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Mon, 02 Nov 2009 17:33:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-not-entering-macro-properly/m-p/10694#M900</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-11-02T17:33:56Z</dc:date>
    </item>
  </channel>
</rss>

