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

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 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Instead of

Call symput ('Dataset',Test);

use

Call symputx ('Dataset',Test);

 

or

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

View solution in original post

2 REPLIES 2
ballardw
Super User

Instead of

Call symput ('Dataset',Test);

use

Call symputx ('Dataset',Test);

 

or

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

KiranMaddi
Obsidian | Level 7
Thank you 🙂

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 2 replies
  • 1316 views
  • 0 likes
  • 2 in conversation