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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.