LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 18 Nov 2004 10:54:04 -0800
Reply-To:     "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Subject:      Re: libref for "work" data sets (one level name): WORK vs USER vs
              User= option

Hey Tammie -

With ODS and proc contents you directly get the "work" libref (active user= or work=) and both physical name and filename. The trick is to not specify the higher level name. If you try to put the results into the "work" library SAS complains a bit, but it still works.

ods listing close; ods output Directory=mysasfolder.work_directory; proc contents data=_all_ ; run; ods output close; ods listing;

About quoted name librefs - you can try them in widows, not just Unix and z/OS:

data 'C:\test'; x=a; run;

You'll see an automatically generated fileref of Wc000001, Wc000002, etc., for each new reference you make.

Online doc:


Paul Choate DDS Data Extraction (916) 654-2160

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Dexter Road Sent: Thursday, November 18, 2004 11:08 AM To: SAS-L@LISTSERV.UGA.EDU 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=&in; %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 dictionary tables? And, if so, what do they look like? Just curious. No real need to know.

Thanks for any assistance or advice, Tammie

Back to: Top of message | Previous page | Main SAS-L page