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

Hi,

i recive this error:

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric
       operand is required. The condition was: &N = 1 AND &MESE_PARTENZA <> -12
ERROR: The macro LOOPMONTH will stop executing.

 

 

from this macro:


%LET DT_START='30APR2018'D; 
%LET PERIDO=12; 
%LET TERM_YM =201804;  
%LET YM = 052018;
%let STRANA = TGSTRANA;  
%let TGERCOM = tggercom; 

/*LDS*/
%LET DT_START_LDS='30APR2018'D; 
%LET PERIDO_LDS=12; 
%LET PERIDO_LDS_PRE = 3; 



 
%macro loopMonth  (PERIDO_LDS_PRE, NAME, MESE_PARTENZA );

  	%let N =1;


    %do %UNTIL( &N = &PERIDO_LDS_PRE + 1)  ;
	 
   	  %if &N = 1 AND  &MESE_PARTENZA  = -12  %then %LET DT_MONTH_LDS = &DT_START_LDS; 
	  %if &N = 1 AND  &MESE_PARTENZA <> -12  %then %LET DT_MONTH_LDS = intnx('month',&DT_MONTH_LDS, &MESE_PARTENZA);  
   	  %if &N > 1 %then %LET DT_MONTH_LDS = intnx('month',&DT_MONTH_LDS, -1);  

		data _null_;
		 call symput('YEAR', YEAR(&DT_MONTH_LDS) );  
		 call symput('MONTH', month(&DT_MONTH_LDS));
		 run;

		data _null_;
		 call symput('YEARMONTH',cats( put(&YEAR.,z4.),put(&MONTH.,z2.)));
		 call symput('YEARMONTH_M',cats(  substr( PUT(&YEAR.,Z4.), length(PUT(&YEAR.,Z4.)) - 1,2), put(&MONTH.,z2.),  'ATMWEB.mdb'  )  );  /* mdb    accdb */
 		 call symput('YEARMONTH_M2',cats(  substr( PUT(&YEAR.,Z4.), length(PUT(&YEAR.,Z4.)) - 1,2), put(&MONTH.,z2.) )  );
		 call symput('MONTH', put(&MONTH.,z2.));
		 call symput('MOLOGATM',cats('MOLOGATM', put(&YEAR.,z4.),put(&MONTH.,z2.)));
		run;
 		

		%put NOTE: &N; 
				
 
					PROC SQL;  
						CREATE TABLE WORK.&NAME&&N AS 
						
						SELECT &YEARMONTH AS YEARMONTH, 
						C.keyatm,  
	 
						/* TOLGO I VALORI ZERO PER NON FALSARE LA MEDIA */
						(CASE
						WHEN C.LdS_prelievo = 0     THEN  .
		 		        ELSE ROUND(C.LdS_prelievo/100,0.0001)
				        END)  as  LDS_PREL LABEL='LDS_PREL', 
		
						(CASE
				        WHEN C.Lds_Vers_Assegni = 0     THEN  .
		 		        ELSE ROUND(C.Lds_Vers_Assegni/100,0.0001)
				        END) AS LDS_VER_AS LABEL='LDS_VER_AS', 


						(CASE
				        WHEN C.LdS_Vers_Contanti = 0     THEN  .
		 		        ELSE ROUND(C.LdS_Vers_Contanti/100,0.0001)
				        END) AS LDS_VER_CO LABEL='LDS_VER_CO'
						,
						c.Carico_filiale,
						c.Carico_problemi_linee,
						c.Carico_assistenza,
						c.Carico_varie_e_inceppamenti, 
						c.Carico_vigilanza

						FROM  LDS.Tcol54_&YEARMONTH_M2  c
				 			
						;	
					quit;
 

	%let N=%eval(&N +1);
   %end;
%mend loopMonth;

 %loopMonth (&PERIDO_LDS_PRE, Z_PRE_A_ , -12 );     

 

 

 

 

Can someone give me advice on how to solve?

thank's so much

1 ACCEPTED SOLUTION

Accepted Solutions
Amir
PROC Star

Hi,

 

The use of <> as an operator in the %if statement is not valid. You can for example use ne instead.

 

See the section on Operands and Operators in:

 

http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#n1alyfc9f4qrten10...

 

You might find you have other issues, for example consider using %eval for integer arithmetic in the %do %until loop control, for starters.

 

 

Regards,

Amir.

 

Edit: Corrected "operand" to be "operator".

View solution in original post

2 REPLIES 2
Amir
PROC Star

Hi,

 

The use of <> as an operator in the %if statement is not valid. You can for example use ne instead.

 

See the section on Operands and Operators in:

 

http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#n1alyfc9f4qrten10...

 

You might find you have other issues, for example consider using %eval for integer arithmetic in the %do %until loop control, for starters.

 

 

Regards,

Amir.

 

Edit: Corrected "operand" to be "operator".

RW9
Diamond | Level 26 RW9
Diamond | Level 26

What is it your trying to do?  Macro is not the place to be doing data processing, and from the looks of it your breaking data up into smaller bits and putting data into dataset names:

CREATE TABLE WORK.&NAME&&N AS

It is rarely a good idea to split like data into blocks, this will just increase storage needs, make your code slower, and you will have to write a lot more messy code.  SAS has built in, and very powerful by group processing to handle these types of things.  In you main dataset, just add another variable which is the grouping - what you would put in the &name&&n - then use this as by <thevariable>;  Far simpler, quicker, less storage etc. and just better all round.  

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 15296 views
  • 1 like
  • 3 in conversation