Help using Base SAS procedures

Error in macro code in WHERE clause

Reply
Occasional Contributor
Posts: 6

Error in macro code in WHERE clause

[ Edited ]

Error for attached program when running in UNIX:

 

NOTE: Line generated by the invoked macro "LOADCPDFIX".
19020 data _null_; set cpdvars; where (CPDCOBRS_GRP_T=&fixcpd and CPDCOBRS_VAR_NM=&var_nm); call
_______________
22
76
19020 ! symput('return_value',CPDCOBRS_RTRN_VLU_1); run;
ERROR: Syntax error while parsing WHERE clause.

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, -, /, <, <=, <>, =, >, >=, AND, EQ, GE, GT,
LE, LT, NE, OR, ^=, |, ||, ~=.

ERROR 76-322: Syntax error, statement will be ignored.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

Attachment
Super User
Posts: 23,662

Re: Macros

I don't see anything jumpling out at me...not that there isn't anything, but why are you doing this:

 

%let fixcpd=&Grouping_Criteria;
%let var_nm=&Var_name;
%let return_value=;

That doesn't add a lot of value to your code, except making it harder to trace and debug.

 

It may help if you include the full log - we can't run the code because we don't have the data. Maybe it's a data issue.

 


@sai99 wrote:

Error for attached program when running in UNIX:

 

NOTE: Line generated by the invoked macro "LOADCPDFIX".
19020 data _null_; set cpdvars; where (CPDCOBRS_GRP_T=&fixcpd and CPDCOBRS_VAR_NM=&var_nm); call
_______________
22
76
19020 ! symput('return_value',CPDCOBRS_RTRN_VLU_1); run;
ERROR: Syntax error while parsing WHERE clause.

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, -, /, <, <=, <>, =, >, >=, AND, EQ, GE, GT,
LE, LT, NE, OR, ^=, |, ||, ~=.

ERROR 76-322: Syntax error, statement will be ignored.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds


 

Occasional Contributor
Posts: 6

Re: Macros

I want to globalize sfixs, pfixs and suffixs but I am trying to avoid using local parametrs as global variables so used different variable names
Super User
Posts: 23,662

Re: Macros

That explains the last part, but not why the first ones are renamed. You're also using them inconsistently, in some places you've used var_name and in some var_nm.  Not sure if that's intentional or not. 

 

This method was historically used to trim spaces, but there are other, better ways to do this now. 

 


@sai99 wrote:
I want to globalize sfixs, pfixs and suffixs but I am trying to avoid using local parametrs as global variables so used different variable names

 

Super User
Posts: 23,662

Re: Error in macro code in WHERE clause

Does the non macro version work as expected?

 

	data _null_;
    set cpdvars;
	where (CPDCOBRS_GRP_T='CTL_log_sfix'
		and CPDCOBRS_VAR_NM=19);
	call symputx('return_value',CPDCOBRS_RTRN_VLU_1);
	run; 
Occasional Contributor
Posts: 6

Re: Error in macro code in WHERE clause

yes data _null_;
set cpdvars;
where (CPDCOBRS_GRP_T=19
and CPDCOBRS_VAR_NM='CTL_log_sfix');
call symputx('return_value',CPDCOBRS_RTRN_VLU_1);
run;

works fine
Super User
Posts: 23,662

Re: Error in macro code in WHERE clause

Then you need to post your full log. 

 


@sai99 wrote:
yes data _null_;
set cpdvars;
where (CPDCOBRS_GRP_T=19
and CPDCOBRS_VAR_NM='CTL_log_sfix');
call symputx('return_value',CPDCOBRS_RTRN_VLU_1);
run;

works fine



Ask a Question
Discussion stats
  • 6 replies
  • 171 views
  • 0 likes
  • 2 in conversation