Hi all,
here is my script below:
%let list=;
%macro fix(suffix);
proc sql noprint;
select name into :vars separated by ' '
from dictionary.columns
where upcase(libname)=upcase('work')
and upcase(memname)=upcase('RN_LIST')
and index(name,upcase("&suffix")) ge 1;
quit;
%let list=&list &vars;
%put &list;
%mend fix;
%fix('2019');
%fix('2018');
%fix('2017');
I am trying to take variables from the past 3 years.
however it keeps duplicating '2019'
could someone please help to fix it?
Hi @ikeum ,
One thing to remember, which may make your macroprogramming easier, macro code operate on texts and treats _everything_ as text so no quotes are needed. In your case when you are passing >>'2019'<< SAS uses all 6 characters: apostrophe, two, zero, one, nine, and apostrophe as macrovariable's value. Do it as @Astounding pointed out, >>2019<<.
All the best
Bart
Just to add to what the others already found: you do not need upcase() on libname and memname. These columns are always uppercase in the dictionary tables. But you should use upcase on name
and index(upcase(name),upcase("&suffix")) ge 1
as column names in SAS can be partially or completely lowercase.
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.