Re: libref for "work" data sets (one level name): WORK vs USER vs User= option
by EdHeaton » Sat, 20 Nov 2004 02:51:37 GMT
kay, it seems that I didn't read the email carefully, so I answered a
question that was not asked. The question should be "How do I find the
libRef for one.level dataset names?"
Ed Heaton
-----Original Message-----
From: Ed Heaton
Sent: Thursday, November 18, 2004 12:32 PM
To: 'Dexter Road'; ' XXXX@XXXXX.COM '
Subject: RE: libref for "work" data sets (one level name): WORK vs USER vs
User= option
Tammie,
That info is stored in SASHELP.VSLIB.
Data _null_ ;
Set sasHelp.vsLib ;
Where ( upCase(libName) eq "WORK" ) ;
Call symPut( "workLoc" , trim(path) ) ;
Run ;
%put "&workLoc" ;
Ed
Edward Heaton, SAS Senior Systems Analyst,
Westat (An Employee-Owned Research Corporation),
1600 Research Boulevard, RW-3541, Rockville, MD 20850-3195
Voice: (301) 610-4818 Fax: (301) 610-5128
mailto: XXXX@XXXXX.COM http://www.Westat.com
-----Original Message-----
From: SAS(r) Discussion [mailto: XXXX@XXXXX.COM ] On Behalf Of Dexter
Road
Sent: Thursday, November 18, 2004 11:08 AM
To: XXXX@XXXXX.COM
Subject: libref for "work" data sets (one level name): WORK vs USER vs User=
option
I thought there was an easy way to determine the libref for "work"
data sets (i.e. those that can be accessed via a one level name), but
I could not find anything on SAS-L or in the on-line doc. Of course,
searching for WORK USER LIBREF can provide a number of non-related
hits (see additonal slightly off topic question at bottom).
I ended up writing the code included below to determine the libname
and memname for one level data set names.
(I need the two level name to extract info from the dictionary tables)
Is there an easier way to figure out the two level name?
=============================================================
%*** get lib & mem;
%macro libmem(in=,lib=_lib,mem=_mem);
%if %scan(&in,2,.)>' ' %then %do;
%*** two level names are easy;
%let &lib=%scan(&in,1,.);
%let &mem=%scan(&in,2,.);
%end;
%else %do;
%*** one level names are more challenging;
%*** if USER option is set, then use it;
%let &lib=%sysfunc(getoption(USER));
%if "&&&lib"="" %then %do;
%*** if no USER option, check USER libref, if there use it;
proc sql noprint;
select distinct libname into :&lib from DICTIONARY.MEMBERS
where libname='USER';
quit;
%*** if no USER libref defined then it must be WORK;
%if "&&&lib"="" %then %let &lib=WORK;
%end;
%let &mem=∈
%end;
%*** upcase for use with dictionary tables;
%let &lib=%upcase(&&&lib);
%let &mem=%upcase(&&&mem);
%put &lib is &&&lib &mem is &&&mem;
%mend;
%libmem(in=sashelp.prdsale);
data prdsale; set sashelp.prdsale(obs=1); run;
%libmem(in=prdsale);
libname USER 'c:\DeleteThisFolder';
data prdsalU; set sashelp.prdsale(obs=1); run;
%libmem(in=prdsalU);
libname altUser 'c:\DeleteThisOneToo';
options user=altUser;
data prdsalO; set sashelp.prdsale(obs=1); run;
%libmem(in=prdsalO);
=============================================================
While looking at the on-line doc I found these:
Files in UNIX System Services can also be specified without a libref.
The following example specifies an HFS file using a relative path:
data 'saswork/two'; x=2; run;
I do not currently have access to a UNIX or OS/390 box, but was
wondering, do data sets accessed in this way show up in the dictio