Hi,
Have searched for a solution for my problem, but can't find it.
I'm using an SQL in a macro, and I want to resolve a macrovariable that needs to be between two single quotes in the WHERE clause:
WHERE t2.CENTRUM = '¢rum'
when resolved, it should look like this:
WHERE t2.CENTRUM = 'centre1'
Whatever I'm trying, I cant resolve ¢rum when it's between the single quotes. Double quotes will resolve it, but I need the single quotes, otherwise my sql will not function.
What am I missing here?
Full code:
%macro create_list_per_centre;
%do c = 1 %to 5;
%if &c = 1 %then %let centrum = centre1;
%else %if &c = 2 %then %let centrum = centre2;
%else %if &c = 3 %then %let centrum = centre3;
%else %if &c = 4 %then %let centrum = centre4;
%else %if &c = 5 %then %let centrum = centre5;
PROC SQL;
CREATE TABLE WORK.¢rum AS
SELECT t2.CENTRUM,
t1.KEY,
(put(t2.YR,4.) || 'm' || strip(put(t2.periode2,2.))) AS PERIODE,
FROM WORK.error_ALL t1
LEFT JOIN tableYYY t2 ON (t1.KEY = t2.KEY)
WHERE t2.CENTRUM = '¢rum'
ORDER BY t2.CENTRUM,
t1.KEY,
t1.error_type;
QUIT;
%end;
%mend;
Here is an example :
%let sex=F;
proc sql;
select *
from sashelp.class
where sex=%unquote(%bquote('&sex'));
quit;
Here is an example :
%let sex=F;
proc sql;
select *
from sashelp.class
where sex=%unquote(%bquote('&sex'));
quit;
Thank you very much, it worked.
Hi
Please also have a look here https://communities.sas.com/docs/DOC-11204
There is a autocall macro %TSLIT that can be used and also an alternative macro provided by @Tom
Bruno
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.