Desktop productivity for business analysts and programmers

How to use & as a Character and not a Macro Variable

Reply
N/A
Posts: 0

How to use & as a Character and not a Macro Variable

Im having a problem with the ampersand quoted after then in the statement below because i've used double quotes SAS thinks that the ampersand is the start of a macro, now the usual way to get round it would be to use single quotes but i can't do this because Italy has an apostrophe and SAS think its end of quote. is there a way of getting round this?

Case
When TotalTours.Brand = "J" and TotalTours.Description = 'Innsbruck & Lake Garda' then "Innsbruck & Italy's Lake Garda" end
Esteemed Advisor
Posts: 5,194

Re: How to use & as a Character and not a Macro Variable

I tried your code and had no problem. Could you attach the log showing your problem?

Regards,
Linus
Data never sleeps
N/A
Posts: 0

Re: How to use & as a Character and not a Macro Variable

the base SAS language includes a function to "hide" the ampersand from normal macro variable handling.
However, since your code is not executing within a macro, the solution is even simpler: Just use single quotes (and repeat any embedded single quote)
Try [pre] then 'Innsbruck & Italy''s Lake Garda' [/pre]

PeterC
Respected Advisor
Posts: 3,822

Re: How to use & as a Character and not a Macro Variable

Single quotes is sure the easiest solution here.
I think what Peter_c is talking about is %nrstr(....).
This means NoResolveString: The macro processor won't resolve the string - especially characters like '&' and '%' with meaning in SAS macro language - but single quotes have the same effect.
HTH
Patrick
Ask a Question
Discussion stats
  • 3 replies
  • 90 views
  • 0 likes
  • 3 in conversation