Getting below error, need a way in order to successfully compress spaces from the string: '0189416','189416','00189416','000189416'.
call symput ('POL_NBR1',compress(&POL_NBR.,'0123456789'));
SYMBOLGEN: Macro variable POL_NBR resolves to '0189416','189416','00189416','000189416'
________
72
ERROR 72-185: The COMPRESS function call has too many arguments.
When the macro variable is resolved, the following statement is handed to the SAS interpreter:
call symput ('POL_NBR1',compress('0189416','189416','00189416','000189416','0123456789'));
You can see that you have 5 arguments for compress(), which only expects 3 arguments at most.
You can enclose your macr variable in double quotes:
%let pol_nbr='0189416','189416','00189416','000189416';
data _null_;
call symput ('POL_NBR1',compress("&POL_NBR.",'0123456789'));
run;
%put pol_nbr1=&pol_nbr1.;
which leaves you with a sequence of empty strings:
43 %put pol_nbr1=&pol_nbr1.; pol_nbr1='','','',''
That worked 🙂 but while using this resolved value in my code, i am not getting the results although it shows it's resolving fine. Here's what i am getting in the log:
where
/* and cov.pol_nbr in('0189416','189416','00189416','000189416')*/
and (cov.pol_nbr in
SYMBOLGEN: Macro variable POL_NBR1 resolves to '0189416','189416','00189416','000189416'
119 ! (&POL_NBR1.))
but when i am including the above commented piece of code, I am able to get the results.
Why is it so ?
Please post the whole log of the step that gives you issues. Use the {i} button for posting logs, to prevent any reformatting or character substitution by the forum software.
On the surface of things, it looks a little odd that you want to remove spaces from a string that doesn't contain any space. But assuming your description of the problem is correct, this statement is obviously not working:
call symput ('POL_NBR1',compress(&POL_NBR.,'0123456789'));
The good news: the solution is even simpler:
call symput ('POL_NBR1',compress("&POL_NBR."'));
With no additional arguments, COMPRESS removes all spaces.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.