Hi
I am trying to add '% before and at the end of a macro variable
it does the job but i cannot avoid the warning.
it seems that it has something to do with the % that sas try to resolve in a certain way.
my code
%MACRO squote(value);
%unquote(%str(%')%qsysfunc(tranwrd(%superq(value),%str(%'),''))%str(%'))
%MEND squote;
%MACRO GET_VIEWS(TABLENAME);
DATA _NULL_;
CALL SYMPUTX ('TABLE', &TABLENAME);
RUN;
%PUT table=&TABLE;
%LET TEST=%squote(%SYSFUNC(CAT(%,&TABLE,%)));
%PUT TEST=&TEST;
%MEND;
%GET_VIEWS('MYTABLE');
Is there a way to escape % and single quotes and add them dynamically
You are overcomplicating this. It is quite easy to "mask" this in a data step by building a string from pieces:
%macro get_views(tablename);
data _null_;
call symputx('table',"'%"!!"&tablename."!!"%'",'g');
run;
%put &=table;
%mend;
%get_views(MYTABLE)
You are overcomplicating this. It is quite easy to "mask" this in a data step by building a string from pieces:
%macro get_views(tablename);
data _null_;
call symputx('table',"'%"!!"&tablename."!!"%'",'g');
run;
%put &=table;
%mend;
%get_views(MYTABLE)
Hi,
You already have the answer for your question, but I'm just guessing that you want to get something like "dynamic like condition" in where clause? If yes, you could do it also like that:
%let table=CLASS;
proc sql;
select * from dictionary.tables
where memname like '%'!!"&table"!!'%'
;
quit;
All the best
Bart
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.