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 🙂

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