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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.

View solution in original post

9 REPLIES 9
PaigeMiller
Diamond | Level 26

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

--
Paige Miller
ratnaparakhee
Obsidian | Level 7
Thanks for looking into my problem. The double quotes was still giving the same error.
I was however able to solve my problem by adding an extra single quote.

Regards
Bhawna
Reeza
Super User

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' ) ;

 

ratnaparakhee
Obsidian | Level 7

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

Reeza
Super User

Second sentence in the answer.....

FreelanceReinh
Jade | Level 19

Hi @ratnaparakhee,

 

Alternatively, you can just duplicate the inner single quote:

'Randomgroup Fl''s dummy'
ratnaparakhee
Obsidian | Level 7

Hi @FreelanceReinh 

Thanks for the solution. This was the easiest way to get rid of my error and my list and macro variable are working fine.

Tom
Super User Tom
Super User

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.

ratnaparakhee
Obsidian | Level 7

Thanks @Tom  for the solution.

I was able to get rid of my error.

 

Regards

Bhawna

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 9 replies
  • 1448 views
  • 4 likes
  • 5 in conversation