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'.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: