<?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: ERROR: A character operand was found where a numeric in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467774#M30334</link>
    <description>&lt;P&gt;Even if he fixes the macro call, it still won't work. The macro processor won't know what to do with the values of &amp;amp;ano_i and &amp;amp;ano_f in the &lt;FONT face="courier new,courier"&gt;%do i=&amp;amp;ano_ini %to &amp;amp;ano_fin;&lt;/FONT&gt; statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The valued of ano_i and probably of all the other macro variables are just plain text, you need them to actually resolve to integers so that they make sense in the %do-loop, so using&amp;nbsp;&lt;FONT face="courier new,courier"&gt;%let ano_i=%sysfunc(year(&amp;amp;data_ini));&amp;nbsp;&lt;FONT face="arial,helvetica,sans-serif"&gt;and similar changes to all the other macro variable definitions is needed.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Jun 2018 17:40:54 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-06-05T17:40:54Z</dc:date>
    <item>
      <title>ERROR: A character operand was found where a numeric</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467767#M30330</link>
      <description>&lt;P&gt;I tried to run the following code but the ERROR (&amp;nbsp;A character operand was found in the %EVAL function or %IF condition where a numeric operand is required) &amp;nbsp;comes out for the&amp;nbsp;loop with &amp;amp;ano_ini. and &amp;amp;ano_fin.&amp;nbsp;Can someone help me figure this out?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let data_ini='01jan2008'd;
%let data_fin='31dec2016'd;

%let data_1=putn(&amp;amp;data_ini.,'mmddyyyy');
%let ano_i=(year(data_1));
%let mes_i=(month(data_1));
%let data_2=putn(&amp;amp;data_fin.,'mmddyyyy');
%let ano_f=(year(data_2));
%let mes_f=(month(data_2));

%macro tabla (ano_ini,mes_ini,ano_fin,mes_fin);
proc sql;
create table serie(data num, taxa num);
%do i=&amp;amp;ano_ini. %to &amp;amp;ano_fin.;
	%do j=&amp;amp;mes_ini. %to &amp;amp;mes_fin.;
		INSERT INTO SERIE
			set data=mdy(&amp;amp;j.,25,&amp;amp;i.),taxa=0.01;		
	%end;
%end;
create table serie as
select data as data format date9., taxa as taxa

from serie;
quit;
%mend;

%tabla (ano_i,mes_i,ano_f,mes_f);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 17:23:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467767#M30330</guid>
      <dc:creator>brunarejani</dc:creator>
      <dc:date>2018-06-05T17:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: A character operand was found where a numeric</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467773#M30333</link>
      <description>&lt;P&gt;This would be significantly easier in a data step loop. You're creating a set of dates in a data set from start to finish? If you explain what you're trying to do, I can show you the data step code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You created macro variables but didn't use them in the call, is that what you intended?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%tabla (ano_i,mes_i,ano_f,mes_f);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Should that be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%tabla (&amp;amp;ano_i, &amp;amp;mes_i, &amp;amp;ano_f, &amp;amp;mes_f);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/213778"&gt;@brunarejani&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried to run the following code but the ERROR (&amp;nbsp;A character operand was found in the %EVAL function or %IF condition where a numeric operand is required) &amp;nbsp;comes out for the&amp;nbsp;loop with &amp;amp;ano_ini. and &amp;amp;ano_fin.&amp;nbsp;Can someone help me figure this out?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let data_ini='01jan2008'd;
%let data_fin='31dec2016'd;

%let data_1=putn(&amp;amp;data_ini.,'mmddyyyy');
%let ano_i=(year(data_1));
%let mes_i=(month(data_1));
%let data_2=putn(&amp;amp;data_fin.,'mmddyyyy');
%let ano_f=(year(data_2));
%let mes_f=(month(data_2));

%macro tabla (ano_ini,mes_ini,ano_fin,mes_fin);
proc sql;
create table serie(data num, taxa num);
%do i=&amp;amp;ano_ini. %to &amp;amp;ano_fin.;
	%do j=&amp;amp;mes_ini. %to &amp;amp;mes_fin.;
		INSERT INTO SERIE
			set data=mdy(&amp;amp;j.,25,&amp;amp;i.),taxa=0.01;		
	%end;
%end;
create table serie as
select data as data format date9., taxa as taxa

from serie;
quit;
%mend;

%tabla (ano_i,mes_i,ano_f,mes_f);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 17:33:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467773#M30333</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-05T17:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: A character operand was found where a numeric</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467774#M30334</link>
      <description>&lt;P&gt;Even if he fixes the macro call, it still won't work. The macro processor won't know what to do with the values of &amp;amp;ano_i and &amp;amp;ano_f in the &lt;FONT face="courier new,courier"&gt;%do i=&amp;amp;ano_ini %to &amp;amp;ano_fin;&lt;/FONT&gt; statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The valued of ano_i and probably of all the other macro variables are just plain text, you need them to actually resolve to integers so that they make sense in the %do-loop, so using&amp;nbsp;&lt;FONT face="courier new,courier"&gt;%let ano_i=%sysfunc(year(&amp;amp;data_ini));&amp;nbsp;&lt;FONT face="arial,helvetica,sans-serif"&gt;and similar changes to all the other macro variable definitions is needed.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 17:40:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467774#M30334</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-06-05T17:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: A character operand was found where a numeric</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467776#M30335</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;Yes, the errors initially mentioned are gone and s/he will have new ones.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I still think a data step is a better approach though.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 17:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467776#M30335</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-05T17:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: A character operand was found where a numeric</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467777#M30336</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I still think a data step is a better approach though.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In the English language, there is a phrase "Listen to reason".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here in the SAS communities, it should say "Listen to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;"&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 17:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467777#M30336</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-06-05T17:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: A character operand was found where a numeric</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467781#M30337</link>
      <description>&lt;P&gt;Here the SASLOG &lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;including the OPTIONS MPRINT and the %put s for the variables.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;1                                        The SAS System              11:20 Tuesday, June 5, 2018

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Program';
4          %LET _CLIENTPROJECTPATH=[hiden];
5          %LET _CLIENTPROJECTNAME='Project 2.egp';
6          %LET _SASPROGRAMFILE=;
7          
8          ODS _ALL_ CLOSE;
9          OPTIONS DEV=ACTIVEX;
NOTE: Procedures may not support all options or statements for all devices. For details, see 
      the documentation for each procedure.
10         GOPTIONS XPIXELS=0 YPIXELS=0;
11         FILENAME EGSR TEMP;
12         ODS tagsets.sasreport12(ID=EGSR) FILE=EGSR STYLE=Analysis
12       ! STYLESHEET=(URL="[hiden]") NOGTITLE NOGFOOTNOTE GPATH=&amp;amp;sasworklocation ENCODING=UTF8 options(rolap="on");
NOTE: Writing TAGSETS.SASREPORT12(EGSR) Body file: EGSR
13         
14         GOPTIONS ACCESSIBLE;
15         OPTIONS MPRINT;
16         
17         %let data_ini='01jan2008'd;
18         %let data_fin='31dec2016'd;
19         
20         %let data_1=putn(&amp;amp;data_ini.,'mmddyyyy');
21         %let ano_i=year(data_1);
22         %let mes_i=month(data_1);
23         %let data_2=putn(&amp;amp;data_fin.,'mmddyyyy');
24         %let ano_f=year(data_2);
25         %let mes_f=month(data_2);
26         
27         %put ano_i is: &amp;amp;ano_i;
ano_i is: year(data_1)
28         %put mes_i is: &amp;amp;mes_i;
mes_i is: month(data_1)
29         %put ano_f is: &amp;amp;ano_f;
ano_f is: year(data_2)
30         %put mes_f is: &amp;amp;mes_f;
mes_f is: month(data_2)
31         
32         %macro tabla (ano_ini,mes_ini,ano_fin,mes_fin);
33         proc sql;
34         create table serie(data num, taxa num);
35         %do i=&amp;amp;ano_ini. %to &amp;amp;ano_fin.;
36         	%do j=&amp;amp;mes_ini. %to &amp;amp;mes_fin.;
37         		INSERT INTO SERIE
38         			set data=mdy(&amp;amp;j.,25,&amp;amp;i.),taxa=0.01;		
39         	%end;
40         %end;
41         create table serie as
42         select data as data format date9., taxa as taxa
43         
44         from serie;
2                                        The SAS System              11:20 Tuesday, June 5, 2018

45         quit;
46         %mend;
47         
48         %tabla (ano_i,mes_i,ano_f,mes_f);


MPRINT(TABLA):   proc sql;
MPRINT(TABLA):   create table serie(data num, taxa num);
NOTE: Table WORK.SERIE created, with 0 rows and 2 columns.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric 
       operand is required. The condition was: &amp;amp;ano_ini. 
ERROR: The %FROM value of the %DO I loop is invalid.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric 
       operand is required. The condition was: &amp;amp;ano_fin. 
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro TABLA will stop executing.
49         
50         
51         
52         
53         GOPTIONS NOACCESSIBLE;
54         %LET _CLIENTTASKLABEL=;
55         %LET _CLIENTPROJECTPATH=;
56         %LET _CLIENTPROJECTNAME=;
57         %LET _SASPROGRAMFILE=;
58         
59         ;*';*";*/;quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      
59       !                run;
60         ODS _ALL_ CLOSE;
61         
62         
63         QUIT; RUN;
64         &lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jun 2018 17:57:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467781#M30337</guid>
      <dc:creator>brunarejani</dc:creator>
      <dc:date>2018-06-05T17:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: A character operand was found where a numeric</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467782#M30338</link>
      <description>&lt;P&gt;You are creating macro variables with text that look like calls to SAS functions. You could do that if you used them in a place where SAS is able to evaluate functions.&lt;/P&gt;
&lt;P&gt;Not sure why you would even want to try to do this with SQL. Much easier to create data using a data step where you can have DO loops.&lt;/P&gt;
&lt;P&gt;So converting your %DO loops into DO loops you would get something like this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro tabla (ano_ini,mes_ini,ano_fin,mes_fin);
data serie ;
  length data taxa 8;
 do year=&amp;amp;ano_ini. to &amp;amp;ano_fin.;
   do month=&amp;amp;mes_ini. to &amp;amp;mes_fin.;
	data=mdy(month,25,year) ;
        taxa=0.01;
        output;
   end;
 end;
 format data date9. ;
 drop month year;
run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But the logic looks really strange since if you called it with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%tabla(2015,5,2017,12);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It would generate records for only the months of may to december data for all of the years from 2015 to 2017.&lt;/P&gt;
&lt;P&gt;Is that what you wanted?&lt;/P&gt;
&lt;P&gt;Or did you want to generate data for all of the months from may-2015 to december-2017?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro tabla (start,stop);
data serie ;
  length data taxa 8;
  do i=0 to intck('month',start,stop);
    data=intnx('month,start,i,'b') + 24 ;
    taxa=0.01;
    output;
  end;
  format data date9. ;
  drop i;
run;
%mend;
%tabla("01MAY2015"d,"01DEC2017"d);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jun 2018 17:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467782#M30338</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-05T17:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: A character operand was found where a numeric</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467784#M30339</link>
      <description>&lt;P&gt;Here's a data step approach. You can wrap it in a macro if desired. The code is commented for clarity.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let data_ini='01jan2008'd;
%let data_fin='31dec2016'd;


data serie;
    *calculate the number of months needed;
    n_months = intck('month', &amp;amp;data_ini, &amp;amp;data_fin);
    taxa=0.01; *set variable to value, will be constant;

    *decrement date to start properly;
    date = intnx('month', &amp;amp;data_ini, -1, 'b') + 24; *increment to 25th day;

    *loop and output date;
    do i=0 to n_months;
        date = intnx('month', date, 1, 's'); *increment date each month;
        output;
    end;

    format date date9.;
    keep date taxa;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jun 2018 17:59:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-A-character-operand-was-found-where-a-numeric/m-p/467784#M30339</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-05T17:59:40Z</dc:date>
    </item>
  </channel>
</rss>

