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

Hi All,

I am having a question regarding how to mask "&" in data steps:

Now I have a variable called "A&C name" in a table, when I call this variable using "A&C name"n, it returns an error showing that SAS interprets "&" as start of a macro var. I wonder how I can mask "&" here? I tried to search the discussions but didn't find a close match.

Thanks for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Use single quotes, not double quotes. Or if for some reason double-quotes are mandatory (I can't think of a reason why it would be mandatory, but maybe...) use %nrstr(&)

 

--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

Use single quotes, not double quotes. Or if for some reason double-quotes are mandatory (I can't think of a reason why it would be mandatory, but maybe...) use %nrstr(&)

 

--
Paige Miller
brokenpc1
Fluorite | Level 6

Hi @PaigeMiller , thanks for helping out. Single quote works for me. Feel like this is one of those rare cases double quote is not working in SAS.

PaigeMiller
Diamond | Level 26

@brokenpc1 wrote:

Hi @PaigeMiller , thanks for helping out. Single quote works for me. Feel like this is one of those rare cases double quote is not working in SAS.


SAS is doing what it is supposed to be doing when you use double-quotes, but that doesn't seem to be what you want it to do.

--
Paige Miller
Tom
Super User Tom
Super User

@PaigeMiller wrote:

@brokenpc1 wrote:

Hi @PaigeMiller , thanks for helping out. Single quote works for me. Feel like this is one of those rare cases double quote is not working in SAS.


SAS is doing what it is supposed to be doing when you use double-quotes, but that doesn't seem to be what you want it to do.


Did anyone else notice that each reply seems to be doubling the & in the subject line?

 

Tom_0-1689865043501.png

 

 

 

PaigeMiller
Diamond | Level 26

Yes, I see it. Calling @ChrisHemedinger 

--
Paige Miller

sas-innovate-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

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
  • 5 replies
  • 374 views
  • 3 likes
  • 3 in conversation