<?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: what's wrong with the following macro function and its invocation? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/what-s-wrong-with-the-following-macro-function-and-its/m-p/897626#M354726</link>
    <description>&lt;PRE&gt;%do i=1 %to %SQLOBS;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;should say&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=1 %to &amp;amp;SQLOBS;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 06 Oct 2023 18:13:08 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-10-06T18:13:08Z</dc:date>
    <item>
      <title>what's wrong with the following macro function and its invocation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-s-wrong-with-the-following-macro-function-and-its/m-p/897625#M354725</link>
      <description>&lt;P&gt;I am using the online sas studio.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code is as follows,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro allcylinders;
proc sql noprint;
select distinct Cylinders
into :val1-
from sashelp.cars
where Cylinders ne .;
quit;

%put &amp;amp;=SQLOBS;

%do i=1 %to %SQLOBS;
title "&amp;amp;&amp;amp;val%i-Cylinder Cars";
proc print data=sashelp.cars noobs;
var Make Model Type Origin MSRP MPG_City MPG_Highway;
where Cylinders=&amp;amp;&amp;amp;val&amp;amp;i;
run;
%end;
%mend allcylinders;


%allcylinders&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The macro compilation passes successfully. When I run the macro, it complains the following,&lt;/P&gt;&lt;PRE&gt;SQLOBS=7

WARNING: Apparent invocation of macro SQLOBS not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
%SQLOBS
ERROR: The %TO value of the %DO I loop is invalid.&lt;/PRE&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;But as I printed on the screen, the macro variable SQLOBS=7, thus I don't understand why it issues the specific WARNING, and then give the next ERROR message.&lt;/DIV&gt;</description>
      <pubDate>Fri, 06 Oct 2023 18:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-s-wrong-with-the-following-macro-function-and-its/m-p/897625#M354725</guid>
      <dc:creator>Newlifewithegg</dc:creator>
      <dc:date>2023-10-06T18:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with the following macro function and its invocation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-s-wrong-with-the-following-macro-function-and-its/m-p/897626#M354726</link>
      <description>&lt;PRE&gt;%do i=1 %to %SQLOBS;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;should say&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=1 %to &amp;amp;SQLOBS;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Oct 2023 18:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-s-wrong-with-the-following-macro-function-and-its/m-p/897626#M354726</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-06T18:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with the following macro function and its invocation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-s-wrong-with-the-following-macro-function-and-its/m-p/897628#M354727</link>
      <description>&lt;P&gt;and also,&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;title "&amp;amp;&amp;amp;val%i-Cylinder Cars";
needs to be 
title "&amp;amp;&amp;amp;val&amp;amp;i-Cylinder Cars";&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Oct 2023 18:20:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-s-wrong-with-the-following-macro-function-and-its/m-p/897628#M354727</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-10-06T18:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with the following macro function and its invocation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-s-wrong-with-the-following-macro-function-and-its/m-p/897641#M354733</link>
      <description>&lt;P&gt;There are two trigger characters that the macro processor looks for to decide if it should intervene.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &amp;amp; is used for referencing macro variables (aka SYMBOLS).&lt;/P&gt;
&lt;P&gt;The % is used for macro statements, functions and user defined macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You tried to call a macro named SQLOBS instead of reference the value of a macro variable named SQLOBS.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 19:04:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-s-wrong-with-the-following-macro-function-and-its/m-p/897641#M354733</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-10-06T19:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with the following macro function and its invocation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-s-wrong-with-the-following-macro-function-and-its/m-p/897647#M354737</link>
      <description>&lt;P&gt;Thank all for your help! Feel so ashamed to have made so stupid mistakes ...&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 20:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-s-wrong-with-the-following-macro-function-and-its/m-p/897647#M354737</guid>
      <dc:creator>Newlifewithegg</dc:creator>
      <dc:date>2023-10-06T20:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with the following macro function and its invocation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-s-wrong-with-the-following-macro-function-and-its/m-p/897648#M354738</link>
      <description>&lt;P&gt;sorry, don't know how to accept more than one solution ..&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 20:42:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-s-wrong-with-the-following-macro-function-and-its/m-p/897648#M354738</guid>
      <dc:creator>Newlifewithegg</dc:creator>
      <dc:date>2023-10-06T20:42:22Z</dc:date>
    </item>
  </channel>
</rss>

