BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gustavotrindade
Calcite | Level 5

Hi everyone, I need some help

 

I have this code and I'm facing the following error:

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:

(&I. GE &ATE.)

ERROR: The condition in the %DO %UNTIL loop, %sysevalf(&I. GE &ATE.), yielded an invalid or missing value, . The macro will stop
executing.
ERROR: The macro LOOP_1 will stop executing.

 

The code:

%MACRO LOOP_1();

	PROC SQL;
	SELECT MAX(CHAVE) /* This is numeric value = 432 */
	INTO :ATE
	FROM SCX.CAMINHO_FORTE_AUX_01;
	QUIT;

	PROC SQL;
	SELECT MIN(CHAVE) /* also a numeric value = 1 */
	INTO :I
	FROM SCX.CAMINHO_FORTE_AUX_01 (WHERE=(CHAVE_FIM = 0));
	QUIT;

	PROC SQL;
	CREATE TABLE REDUZ_01 AS
	SELECT *
	FROM SCX.CAMINHO_FORTE_AUX_01 (WHERE=(CHAVE_FIM = 0));
	QUIT;

	%DO %UNTIL (&I. GE &ATE.); 

	DATA SCX.CAMINHO_FORTE_AUX_01_BACK;
	SET SCX.CAMINHO_FORTE_AUX_01;
	IF CHAVE_FIM > 0;
	RUN;

	DATA REDUZ_01;
	SET SCX.CAMINHO_FORTE_AUX_01;
	IF CHAVE_FIM = 0;
	RUN;

	%LOOP_2(&I.);

	PROC SQL;
	SELECT CASE WHEN MIN(CHAVE) IS NULL THEN &ATE. ELSE MIN(CHAVE) END
	INTO :I
	FROM SCX.CAMINHO_FORTE_AUX_01 (WHERE=(CHAVE > 1 AND CHAVE_FIM = 0));
	QUIT;

	%END;

%MEND;

%MACRO LOOP_2(I);

	PROC SQL;
	SELECT LCF, LCF_01, LCF_02, LCF_03, UEV
	INTO :LCF, :LCF_01, :LCF_02, :LCF_03, :UEV
	FROM CAMINHO_FORTE_AUX_02
	WHERE CHAVE=&I.;
	QUIT;

	PROC SQL;
	CREATE TABLE REDUZ_02 AS
	SELECT *
	FROM REDUZ_01 
	WHERE CAMINHO_FORTE_AUX LIKE &LCF_01.
	AND   CAMINHO_FORTE_AUX LIKE &LCF_02.
	AND   CAMINHO_FORTE_AUX LIKE &LCF_03.
	AND   CAMINHO_FORTE_AUX LIKE &UEV.;
	QUIT;

	PROC SQL;
	CREATE TABLE CHAVE_AUX AS
	SELECT CHAVE
	FROM REDUZ_02
	WHERE CAMINHO_FORTE_AUX LIKE &LCF.;
	QUIT;

	PROC SQL;	
	CREATE TABLE CAMINHO_FORTE_AUX_01 AS
	SELECT 	*, 
			CASE WHEN TT_EVENTOS_CLIENTE_CF = 1 THEN CHAVE
				 WHEN CHAVE IN (SELECT * FROM CHAVE_AUX) AND CHAVE_FIM = 0 THEN &I. END AS AUX
	FROM SCX.CAMINHO_FORTE_AUX_01 A;
	QUIT;
	
	DATA SCX.CAMINHO_FORTE_AUX_01 (DROP=AUX);
	SET CAMINHO_FORTE_AUX_01;
	IF AUX = &I. AND CHAVE_FIM = 0 THEN CHAVE_FIM = AUX;
	RUN;

%MEND;

%LOOP_1();

I tried to use %sysevalf, >=, GE, but with no success. 

 

None of the solutions I found in the internet about this error helped me, I'm totally lost.

 

Thanks!!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 
       &I.>=&ATE. 

Please add a command just before the %DO WHILE that prints out the values of the macro variable &i and the macro variable &ate and see what they are. Obviously, one or both of them make doing the comparison impossible.

--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Please show us the entire log for this macro. Please do NOT show us the errors in the log disconnected from the code.

 

Insert the command 

options mprint;

before you call the macro, run it again and show us the log.

 

To show us the log properly, and to preserve formatting to make it more readable, copy the log for this macro as text, paste it into the window that appears when you click on the </> icon. This preserves the formatting and makes it more readable. I no longer try to decipher logs that are not formatted properly.

--
Paige Miller
gustavotrindade
Calcite | Level 5
1                                                          The SAS System                    Wednesday, January 27, 2021 09:11:00 AM

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='FIO DA MEADA';
4          %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5          %LET _CLIENTPROJECTPATH='d:\Users\z141983\Documents\Claro\Ferramentas Analytics\x_Processamento\02_FIO_DA_MEADA.egp';
6          %LET _CLIENTPROJECTPATHHOST='BCP11N002857';
7          %LET _CLIENTPROJECTNAME='02_FIO_DA_MEADA.egp';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=SVG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         %macro HTML5AccessibleGraphSupported;
15             %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) >= 0 %then ACCESSIBLE_GRAPH;
16         %mend;
17         FILENAME EGHTML TEMP;
18         ODS HTML5(ID=EGHTML) FILE=EGHTML
19             OPTIONS(BITMAP_MODE='INLINE')
20             %HTML5AccessibleGraphSupported
21             ENCODING='utf-8'
22             STYLE=HtmlBlue
23             NOGTITLE
24             NOGFOOTNOTE
25             GPATH=&sasworklocation
26         ;
NOTE: Writing HTML5(EGHTML) Body file: EGHTML
27         
28         options mprint;
29         
30         %MACRO LOOP_1();
31         
32         	PROC SQL;
33         	SELECT MAX(CHAVE)
34         	INTO :ATE
35         	FROM SCX.CAMINHO_FORTE_AUX_01;
36         	QUIT;
37         
38         	PROC SQL;
39         	SELECT MIN(CHAVE)
40         	INTO :I
41         	FROM SCX.CAMINHO_FORTE_AUX_01 (WHERE=(CHAVE_FIM = 0));
42         	QUIT;
43         
44         	PROC SQL;
45         	CREATE TABLE REDUZ_01 AS
46         	SELECT *
47         	FROM SCX.CAMINHO_FORTE_AUX_01 (WHERE=(CHAVE_FIM = 0));
48         	QUIT;
49         
50         	%DO %UNTIL (&I.>=&ATE.);
51         
52         	DATA SCX.CAMINHO_FORTE_AUX_01_BACK;
53         	SET SCX.CAMINHO_FORTE_AUX_01;
54         	IF CHAVE_FIM > 0;
55         	RUN;
56         
57         	DATA REDUZ_01;
2                                                          The SAS System                    Wednesday, January 27, 2021 09:11:00 AM

58         	SET SCX.CAMINHO_FORTE_AUX_01;
59         	IF CHAVE_FIM = 0;
60         	RUN;
61         
62         	%LOOP_2(&I.);
63         
64         	PROC SQL;
65         	SELECT CASE WHEN MIN(CHAVE) IS NULL THEN &ATE. ELSE MIN(CHAVE) END
66         	INTO :I
67         	FROM SCX.CAMINHO_FORTE_AUX_01 (WHERE=(CHAVE > 1 AND CHAVE_FIM = 0));
68         	QUIT;
69         
70         	%END;
71         
72         %MEND;
73         
74         %MACRO LOOP_2(I);
75         
76         	PROC SQL;
77         	SELECT LCF, LCF_01, LCF_02, LCF_03, UEV
78         	INTO :LCF, :LCF_01, :LCF_02, :LCF_03, :UEV
79         	FROM CAMINHO_FORTE_AUX_02
80         	WHERE CHAVE=&I.;
81         	QUIT;
82         
83         	PROC SQL;
84         	CREATE TABLE REDUZ_02 AS
85         	SELECT *
86         	FROM REDUZ_01
87         	WHERE CAMINHO_FORTE_AUX LIKE &LCF_01.
88         	AND   CAMINHO_FORTE_AUX LIKE &LCF_02.
89         	AND   CAMINHO_FORTE_AUX LIKE &LCF_03.
90         	AND   CAMINHO_FORTE_AUX LIKE &UEV.;
91         	QUIT;
92         
93         	PROC SQL;
94         	CREATE TABLE CHAVE_AUX AS
95         	SELECT CHAVE
96         	FROM REDUZ_02
97         	WHERE CAMINHO_FORTE_AUX LIKE &LCF.;
98         	QUIT;
99         
100        	PROC SQL;	
101        	CREATE TABLE CAMINHO_FORTE_AUX_01 AS
102        	SELECT 	*,
103        			CASE WHEN TT_EVENTOS_CLIENTE_CF = 1 THEN CHAVE
104        				 WHEN CHAVE IN (SELECT * FROM CHAVE_AUX) AND CHAVE_FIM = 0 THEN &I. END AS AUX
105        	FROM SCX.CAMINHO_FORTE_AUX_01 A;
106        	QUIT;
107        	
108        	DATA SCX.CAMINHO_FORTE_AUX_01 (DROP=AUX);
109        	SET CAMINHO_FORTE_AUX_01;
110        	IF AUX = &I. AND CHAVE_FIM = 0 THEN CHAVE_FIM = AUX;
111        	RUN;
112        
113        %MEND;
114        
115        %LOOP_1();
3                                                          The SAS System                    Wednesday, January 27, 2021 09:11:00 AM

MPRINT(LOOP_1):   PROC SQL;
MPRINT(LOOP_1):   SELECT MAX(CHAVE) INTO :ATE FROM SCX.CAMINHO_FORTE_AUX_01;
MPRINT(LOOP_1):   QUIT;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      user cpu time       0.01 seconds
      system cpu time     0.01 seconds
      memory              5773.37k
      OS Memory           27300.00k
      Timestamp           01/27/2021 10:58:04 AM
      Step Count                        149  Switch Count  4
      Page Faults                       0
      Page Reclaims                     68
      Page Swaps                        0
      Voluntary Context Switches        78
      Involuntary Context Switches      0
      Block Input Operations            304
      Block Output Operations           0
      

MPRINT(LOOP_1):   PROC SQL;
MPRINT(LOOP_1):   SELECT MIN(CHAVE) INTO :I FROM SCX.CAMINHO_FORTE_AUX_01 (WHERE=(CHAVE_FIM = 0));
MPRINT(LOOP_1):   QUIT;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      user cpu time       0.01 seconds
      system cpu time     0.00 seconds
      memory              5660.65k
      OS Memory           27300.00k
      Timestamp           01/27/2021 10:58:04 AM
      Step Count                        150  Switch Count  4
      Page Faults                       0
      Page Reclaims                     58
      Page Swaps                        0
      Voluntary Context Switches        84
      Involuntary Context Switches      0
      Block Input Operations            288
      Block Output Operations           0
      

MPRINT(LOOP_1):   PROC SQL;
MPRINT(LOOP_1):   CREATE TABLE REDUZ_01 AS SELECT * FROM SCX.CAMINHO_FORTE_AUX_01 (WHERE=(CHAVE_FIM = 0));
NOTE: Compressing data set WORK.REDUZ_01 decreased size by 99.78 percent. 
      Compressed is 1 pages; un-compressed would require 453 pages.
NOTE: Table WORK.REDUZ_01 created, with 453 rows and 7 columns.

MPRINT(LOOP_1):   QUIT;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.02 seconds
      user cpu time       0.01 seconds
      system cpu time     0.00 seconds
      memory              5774.37k
      OS Memory           27300.00k
      Timestamp           01/27/2021 10:58:04 AM
      Step Count                        151  Switch Count  5
      Page Faults                       0
      Page Reclaims                     84
      Page Swaps                        0
4                                                          The SAS System                    Wednesday, January 27, 2021 09:11:00 AM

      Voluntary Context Switches        92
      Involuntary Context Switches      0
      Block Input Operations            288
      Block Output Operations           264
      

MPRINT(LOOP_1):   DATA SCX.CAMINHO_FORTE_AUX_01_BACK;
MPRINT(LOOP_1):   SET SCX.CAMINHO_FORTE_AUX_01;
MPRINT(LOOP_1):   IF CHAVE_FIM > 0;
MPRINT(LOOP_1):   RUN;

NOTE: There were 453 observations read from the data set SCX.CAMINHO_FORTE_AUX_01.
NOTE: The data set SCX.CAMINHO_FORTE_AUX_01_BACK has 0 observations and 7 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      user cpu time       0.00 seconds
      system cpu time     0.01 seconds
      memory              1356.43k
      OS Memory           22436.00k
      Timestamp           01/27/2021 10:58:04 AM
      Step Count                        152  Switch Count  4
      Page Faults                       0
      Page Reclaims                     110
      Page Swaps                        0
      Voluntary Context Switches        365
      Involuntary Context Switches      7
      Block Input Operations            320
      Block Output Operations           264
      

MPRINT(LOOP_1):   DATA REDUZ_01;
MPRINT(LOOP_1):   SET SCX.CAMINHO_FORTE_AUX_01;
MPRINT(LOOP_1):   IF CHAVE_FIM = 0;
MPRINT(LOOP_1):   RUN;

NOTE: There were 453 observations read from the data set SCX.CAMINHO_FORTE_AUX_01.
NOTE: The data set WORK.REDUZ_01 has 453 observations and 7 variables.
NOTE: Compressing data set WORK.REDUZ_01 decreased size by 99.78 percent. 
      Compressed is 1 pages; un-compressed would require 453 pages.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      user cpu time       0.02 seconds
      system cpu time     0.00 seconds
      memory              1121.37k
      OS Memory           22436.00k
      Timestamp           01/27/2021 10:58:04 AM
      Step Count                        153  Switch Count  5
      Page Faults                       0
      Page Reclaims                     80
      Page Swaps                        0
      Voluntary Context Switches        78
      Involuntary Context Switches      22
      Block Input Operations            288
      Block Output Operations           264
      

MPRINT(LOOP_2):   PROC SQL;
MPRINT(LOOP_2):   SELECT LCF, LCF_01, LCF_02, LCF_03, UEV INTO :LCF, :LCF_01, :LCF_02, :LCF_03, :UEV FROM CAMINHO_FORTE_AUX_02 
5                                                          The SAS System                    Wednesday, January 27, 2021 09:11:00 AM

WHERE CHAVE=1;
MPRINT(LOOP_2):   QUIT;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      user cpu time       0.01 seconds
      system cpu time     0.00 seconds
      memory              5989.96k
      OS Memory           27300.00k
      Timestamp           01/27/2021 10:58:04 AM
      Step Count                        154  Switch Count  0
      Page Faults                       0
      Page Reclaims                     161
      Page Swaps                        0
      Voluntary Context Switches        0
      Involuntary Context Switches      1
      Block Input Operations            0
      Block Output Operations           0
      

MPRINT(LOOP_2):   PROC SQL;
NOTE: The quoted string currently being processed has become more than 262 bytes long.  You might have unbalanced quotation marks.
MPRINT(LOOP_2):   CREATE TABLE REDUZ_02 AS SELECT * FROM REDUZ_01 WHERE CAMINHO_FORTE_AUX LIKE '' AND CAMINHO_FORTE_AUX LIKE '' AND 
CAMINHO_FORTE_AUX LIKE '' AND CAMINHO_FORTE_AUX LIKE
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 
       &I.>=&ATE. 
ERROR: The condition in the %DO %UNTIL loop, &I.>=&ATE., yielded an invalid or missing value, .  The macro will stop executing.
ERROR: The macro LOOP_1 will stop executing.
116        
117        %LET _CLIENTTASKLABEL=;
118        %LET _CLIENTPROCESSFLOWNAME=;
119        %LET _CLIENTPROJECTPATH=;
120        %LET _CLIENTPROJECTPATHHOST=;
121        %LET _CLIENTPROJECTNAME=;
122        %LET _SASPROGRAMFILE=;
123        %LET _SASPROGRAMFILEHOST=;
124        
125        ;*';
MPRINT(LOOP_2):   '%                                                                                                                
                                                                                      ;  QUIT;   PROC SQL;  CREATE TABLE CHAVE_AUX 
AS  SELECT CHAVE  FROM REDUZ_02  WHERE CAMINHO_FORTE_AUX LIKE &LCF.;  QUIT;   PROC SQL;   CREATE TABLE CAMINHO_FORTE_AUX_01 AS  
SELECT  *,     CASE WHEN TT_EVENTOS_CLIENTE_CF = 1 THEN CHAVE      WHEN CHAVE IN (SELECT * FROM CHAVE_AUX) AND CHAVE_FIM = 0 THEN 
&I. END AS AUX  FROM SCX.CAMINHO_FORTE_AUX_01 A;  QUIT;    DATA SCX.CAMINHO_FORTE_AUX_01 (DROP=AUX);  SET CAMINHO_FORTE_AUX_01;  IF 
AUX = &I. AND CHAVE_FIM = 0 THEN CHAVE_FIM = AUX;  RUN;;   PROC SQL;  SELECT CASE WHEN MIN(CHAVE) IS NULL THEN &ATE. ELSE 
MIN(CHAVE) END  INTO :I  FROM SCX.CAMINHO_FORTE_AUX_01 (WHERE=(CHAVE > 1 AND CHAVE_FIM = 0));  QUIT;;%LET _CLIENTTASKLABEL=;%LET 
_CLIENTPROCESSFLOWNAME=;%LET _CLIENTPROJECTPATH=;%LET _CLIENTPROJECTPATHHOST=;%LET _CLIENTPROJECTNAME=;%LET _SASPROGRAMFILE=;%LET 
_SASPROGRAMFILEHOST=;;*'
NOTE: Table WORK.REDUZ_02 created, with 0 rows and 7 columns.

125      !     *";*/;quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      memory              5627.12k
      OS Memory           27812.00k
      Timestamp           01/27/2021 10:58:04 AM
      Step Count                        155  Switch Count  26                                                          The SAS System                    Wednesday, January 27, 2021 09:11:00 AM
      Page Faults                       0
      Page Reclaims                     122
      Page Swaps                        0
      Voluntary Context Switches        14
      Involuntary Context Switches      1
      Block Input Operations            0
      Block Output Operations           264
      
125      !                run;
126        ODS _ALL_ CLOSE;
127        
128        
129        QUIT; RUN;
130        
PaigeMiller
Diamond | Level 26
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 
       &I.>=&ATE. 

Please add a command just before the %DO WHILE that prints out the values of the macro variable &i and the macro variable &ate and see what they are. Obviously, one or both of them make doing the comparison impossible.

--
Paige Miller
gustavotrindade
Calcite | Level 5

I printed the step by step of the macro as you suggested and I found the error. The 1st rows was wrong already, it was empty. So I fixed the code from this:

38         	PROC SQL;
39         	SELECT MIN(CHAVE)
40         	INTO :I
41         	FROM SCX.CAMINHO_FORTE_AUX_01

to this:

38         	PROC SQL;
39         	SELECT MIN(CHAVE)+1
40         	INTO :I
41         	FROM SCX.CAMINHO_FORTE_AUX_01

Now I'm back to business, thanks for yor help @PaigeMiller 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3227 views
  • 1 like
  • 2 in conversation