- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 09-21-2010 03:09 PM
(1511 views)
I'm trying to check to see if a library has been assisgned and have copied this verbatim out of the documentation. I'm using the SASHELP library for testing. It doesn't seem to work. I know I've done this before and can't see what exactly I'm doing wrong. Does it not work in enterprise guide?
%macro test (lib=SASHELP);
%if (%sysfunc(LIBREF(&lib))) %then
%put %sysfunc(sysmsg());
%mend;
%test;
As a check(of my sanity), I check the libname definitions with the following SQL and it shows up. Any thoughts?
proc sql;
create table one as select distinct libname
from dictionary.libnames;
Here's the log
19 %macro test (lib=SASHELP);
20 %if (%sysfunc(LIBREF(&lib))) %then
21 %put %sysfunc(sysmsg());
22 %mend;
23 %test;
MLOGIC(TEST): Beginning execution.
MLOGIC(TEST): Parameter LIB has value SASHELP
SYMBOLGEN: Macro variable LIB resolves to SASHELP
MLOGIC(TEST): %IF condition (%sysfunc(LIBREF(&lib))) is FALSE
MLOGIC(TEST): Ending execution.
24 *%LET RC = %sysfunc(libref(INTGRP)) ; %put &RC;
SYMBOLGEN: Macro variable RC resolves to 0
and the sql output.......
AGRGRP
CHEGRP
ENEGRP
INDGRP
INTGRP
MAPS
SASHELP
SASUSER
WORK
Thanks
%macro test (lib=SASHELP);
%if (%sysfunc(LIBREF(&lib))) %then
%put %sysfunc(sysmsg());
%mend;
%test;
As a check(of my sanity), I check the libname definitions with the following SQL and it shows up. Any thoughts?
proc sql;
create table one as select distinct libname
from dictionary.libnames;
Here's the log
19 %macro test (lib=SASHELP);
20 %if (%sysfunc(LIBREF(&lib))) %then
21 %put %sysfunc(sysmsg());
22 %mend;
23 %test;
MLOGIC(TEST): Beginning execution.
MLOGIC(TEST): Parameter LIB has value SASHELP
SYMBOLGEN: Macro variable LIB resolves to SASHELP
MLOGIC(TEST): %IF condition (%sysfunc(LIBREF(&lib))) is FALSE
MLOGIC(TEST): Ending execution.
24 *%LET RC = %sysfunc(libref(INTGRP)) ; %put &RC;
SYMBOLGEN: Macro variable RC resolves to 0
and the sql output.......
AGRGRP
CHEGRP
ENEGRP
INDGRP
INTGRP
MAPS
SASHELP
SASUSER
WORK
Thanks
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc sql;
create view uxwrk.OldDataSets as
select distinct memname as memname
from dictionary.tables
where upcase(libname)=SASHELP' and memtype='DATA'
order by memname
;
quit;
proc sql noprint; /*Create macro var to be used in filtering out the crooks*/
select memname into :ds1 - :ds45
from OldDataSets;
quit;
%put &ds45;
create view uxwrk.OldDataSets as
select distinct memname as memname
from dictionary.tables
where upcase(libname)=SASHELP' and memtype='DATA'
order by memname
;
quit;
proc sql noprint; /*Create macro var to be used in filtering out the crooks*/
select memname into :ds1 - :ds45
from OldDataSets;
quit;
%put &ds45;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The libref function returns a zero (not a one) if a libref is found. For example, try the following:
%macro test (lib=SASHELP);
%if (%sysfunc(LIBREF(&lib))=0) %then %put Library Assigned;
%mend;
%test;
I'm not sure what the existance of a library has to do with the sysmsg function. The sysmsg function might return a missing value even if the library has been assigned.
%macro test (lib=SASHELP);
%if (%sysfunc(LIBREF(&lib))=0) %then %put Library Assigned;
%mend;
%test;
I'm not sure what the existance of a library has to do with the sysmsg function. The sysmsg function might return a missing value even if the library has been assigned.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ahhh. Just the opposite of what I thought it should be Thanks.