Hello,
I'am using SAS EG 7.3. I am trying to resolve a macro variable but i didn't. How can i do this? I am trying different two format.
Thank you,
/* method-1 */
proc sql noprint;
select count(distinct(name)) into: abc
from dictionary.columns
where
libname = 'aaa' and memname = "%str(%'bbb_&M0.%')" ;
quit;
/* method-2 */
proc sql noprint;
select count(distinct(name)) into: abc
from dictionary.columns
where
libname = 'aaa' and memname = 'bbb_&M0.';
quit;
Try:
proc sql noprint;
select count(distinct(name)) into: abc
from dictionary.columns
where
libname = 'aaa' and memname = "bbb_&M0.";
quit;Bart
Try:
proc sql noprint;
select count(distinct(name)) into: abc
from dictionary.columns
where
libname = 'aaa' and memname = "bbb_&M0.";
quit;Bart
@maozsoy wrote:
Hello,
I'am using SAS EG 7.3. I am trying to resolve a macro variable but i didn't. How can i do this? I am trying different two format.
Thank you,
/* method-1 */ proc sql noprint; select count(distinct(name)) into: abc from dictionary.columns where libname = 'aaa' and memname = "%str(%'bbb_&M0.%')" ; quit; /* method-2 */ proc sql noprint; select count(distinct(name)) into: abc from dictionary.columns where libname = 'aaa' and memname = 'bbb_&M0.'; quit;
macro variable values between single quotes do not resolve. So your memname='bbb_&M0.' will not resolve the value.
A quick example:
%let macv = sometext; %put '&macv.'; %put "&macv.";
The Log will show the second put with the macro variable resolved.
Note that even if you get your macro variables to resolve by using double quotes instead of single quotes, your query will not find any matches. The MEMNAME and LIBNAME values into the DICTIONARY tables (views) are uppercase only. So you can never match 'aaa'.
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!
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.