DATA Step, Macro, Functions and more

Compressing spaces

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 107
Accepted Solution

Compressing spaces

[ Edited ]

Hello all

 

Please help! I am struggling to delete any spaces in the below code

 

 

data _null_;
set want nobs = nobs ;
call symput('nobs',nobs);
stop;
run ;

%put &nobs;

%Macro split (nobs);
%do i = 1 %to &nobs ;
	Data _null_;
	length i 3 ;
	i = &i ;
	set Brands point=i;
		Call symput ('Dataset',Test);		
		stop ;
	run;

		proc sql exec;	
		create table &Dataset(keep = MISC_A_QTE_KEY &dataset:) 
		select * from DAY_DATA		
		where &Dataset._quote_commissionformula <> ' ';
		disconnect from odbc;
		quit;
		run;
	%end;
%mend split;
%split(&nobs);

If you can see the where statement in the proc sql statement , when I try to use a macro variable attached to a string(variable name) there are some trailing spaces in the macro variable which is giving me the follwing error.

 

73: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where 
      the error has occurred.
ERROR 73-322: Expecting an AS.
SYMBOLGEN:  Macro variable DATASET resolves to ZE       
NOTE: Line generated by the macro variable "DATASET".
34          ZE       _quote_commissionformula
                     ________________________
                     22
                     76
MPRINT(SPLIT):   create table ZE (keep = MISC_A_QTE_KEY ZE :) select * from DAY_DATA where ZE 
_quote_commissionformula <> ' ';
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, -, '.', /, <, <=, 
              <>, =, >, >=, AND, EQ, EQT, GE, GET, GROUP, GT, GTT, HAVING, LE, LET, LT, LTT, NE, NET, 
              OR, ORDER, ^=, |, ||, ~=.  

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




As you can see above there is space after ZE . I have tried compbl,trim,compress and they didn't work. Please could somebody help me figure out this?

 

Also attached the dataset where the macro variables are feeding from.Capturexx.JPG

 

Thank you Smiley Happy


Accepted Solutions
Solution
‎10-05-2016 03:50 PM
Super User
Posts: 11,336

Re: Compressing spaces

Posted in reply to KiranMaddi

Instead of

Call symput ('Dataset',Test);

use

Call symputx ('Dataset',Test);

 

or

Call symput ('Dataset',strip(Test));

View solution in original post


All Replies
Solution
‎10-05-2016 03:50 PM
Super User
Posts: 11,336

Re: Compressing spaces

Posted in reply to KiranMaddi

Instead of

Call symput ('Dataset',Test);

use

Call symputx ('Dataset',Test);

 

or

Call symput ('Dataset',strip(Test));

Frequent Contributor
Posts: 107

Re: Compressing spaces

Thank you Smiley Happy
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 209 views
  • 0 likes
  • 2 in conversation