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.
Thank you 🙂
Instead of
Call symput ('Dataset',Test);
use
Call symputx ('Dataset',Test);
or
Call symput ('Dataset',strip(Test));
Instead of
Call symput ('Dataset',Test);
use
Call symputx ('Dataset',Test);
or
Call symput ('Dataset',strip(Test));
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.