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'.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.