%macro car_type(ty=);
proc sql;
create table tmp as
select *
from cars
where upcase(type_new) like "%&ty.%"
;quit;
%mend;
The part highlighted in red triggers an error. How to get around this? Please help. Thanks
Separate the parts, so no macro resolution is tried:
%macro car_type(ty=);
proc sql;
create table tmp as
select *
from sashelp.cars
where upcase(type) like "%"!!"&ty."!!"%"
;
quit;
%mend;
%car_type(ty=SUV)
Wrap the % in the %Nrstr Macro Quoting Function
Thanks for the replying. I tried but empty data is generated.
Would be very helpful if you can show the exact syntax.
This is how I have written based on your suggestion,
where upcase(type_new) like "%nrstr(% &ty.%)"
Separate the parts, so no macro resolution is tried:
%macro car_type(ty=);
proc sql;
create table tmp as
select *
from sashelp.cars
where upcase(type) like "%"!!"&ty."!!"%"
;
quit;
%mend;
%car_type(ty=SUV)
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.