Hi All
I have a list of names that i am trying to add in a macro variable as follows-
%let EXCLUDE =
('Randomgroup Fl's dummy' ,
'Randomgroup &GA' ,
'Randomgroup KY' ,
'Randomgroup NJ' ,
'Randomgroup NM') ;
Later on in want to use it in my program as
proc sql;
create table exclusion_data as
select distinct * from Base_data
where group_name in &exclude. ;
quit;
Now since one of the name in the list (Randomgroup Fl's dummy) has a single quote my program errors out with below error-
The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space
between a quoted string and the succeeding identifier is recommended.
Could you please help with how do i deal with it.
P.S.- I tried to enclose my vales with a double quote while inserting in the macro variable still got the same error.
Thanks
Bhawna
Handle it the exact same way you would if you were not using macro variables.
%let EXCLUDE =
('Randomgroup Fl''s dummy'
,'Randomgroup &GA'
,'Randomgroup KY'
,'Randomgroup NJ'
,'Randomgroup NM'
) ;
PS Don't hide the continuation characters are the ends of the lines. Place them at the front where humans can scan for them quickly.
What happens if you use double quotes in &EXCLUDE (except for the one single quote inside of the first value)?
Also, remove the & from in front of GA
If that still doesn't work, show us the ENTIRE log for your PROC SQL, not selected parts
That usually is a NOTE not an ERROR.
However, macro variables will not resolve with single quotes and you cannot have a single quote in a text that's embedded with single quotes. Those are errors.
Fix it as indicated in the message:
Inserting white space
between a quoted string and the succeeding identifier is recommended.
Add spaces:
%let EXCLUDE =
( "Randomgroup Fl's dummy" ,
"Randomgroup &GA" ,
'Randomgroup KY' ,
'Randomgroup NJ' ,
'Randomgroup NM' ) ;
Thanks @Reeza
I tried to add that extra space between the identifier and quoted string but it still didn't work out.
I was however able to get rid of the error by adding an extra single quote as
'Random group FL' ' s dummy' ,
regards
Bhawna
Second sentence in the answer.....
Hi @ratnaparakhee,
Alternatively, you can just duplicate the inner single quote:
'Randomgroup Fl''s dummy'
Thanks for the solution. This was the easiest way to get rid of my error and my list and macro variable are working fine.
Handle it the exact same way you would if you were not using macro variables.
%let EXCLUDE =
('Randomgroup Fl''s dummy'
,'Randomgroup &GA'
,'Randomgroup KY'
,'Randomgroup NJ'
,'Randomgroup NM'
) ;
PS Don't hide the continuation characters are the ends of the lines. Place them at the front where humans can scan for them quickly.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.