DATA Step, Macro, Functions and more

Unknown default SAS Directory

Reply
Learner
Posts: 1

Unknown default SAS Directory

Hello,

I am using SAS 9.2

 

Location of my default temporary ‘work’ library

%put %sysfunc(getoption(work));

C:\Users\user1\AppData\Local\Temp\SAS Temporary Files\_TD6864_UPLCI087142_

 

But when I run the following code

data temp.set1;

set1=2;

run;

 

and then find location of this ‘TEMP’ library using the following command

 

%put %sysfunc(pathname(temp));

C:\Users\user1\AppData\Local\Temp

 

Question: I am not sure that an automatic libname “temp” exists in SAS. And data stored here are permanent. I could not find this in any SAS documentation.  Can you please explain.

Super User
Super User
Posts: 7,401

Re: Unknown default SAS Directory

No, there is no libname called temp in the default SAS install.  Work is the temporary folder.  The idea is that in your programs - (or if you work on a project or server environment these might be setup for you) - create the references which you use to store you data, work is removed at the end of the session:

libname yourlib "path-to-folder";

 

So path-to-folder is a folder on your local machine, or network where to store data permanently.

Trusted Advisor
Posts: 1,115

Re: Unknown default SAS Directory

Thank you for posting this interesting question. Searching for the answer I discovered this page of the online help (for SAS under Windows):

https://support.sas.com/documentation/cdl/en/hostwin/63285/HTML/default/usedatalibs.htm#useenvvar

 

Quote:

---------------------

When you use a libref in a SAS statement, SAS resolves libref assignments in this order:

  1. a libref assigned by a LIBNAME statement, a LIBNAME function, or by using the New Library dialog box, with the last assignment taking precedence

  2. a libref assigned by a SAS environment variable

  3. a libref assigned by a Windows environment variable.

---------------------

 

In your case I guess that a Windows environment variable TEMP exists (this is the case on my computer, too) and points to the path you've mentioned.

 

You can quickly list the Windows environment variables and their values in the SAS log by submitting the following code:

 

filename ttt pipe 'set';
data _null_;
infile ttt lrecl=5000;
input;
put _infile_;
run;

 

 

A list of the SAS environment variables (see item 2 above) and their values can be obtained as follows:

 

%put %sysfunc(getoption(set));

 

Ask a Question
Discussion stats
  • 2 replies
  • 197 views
  • 1 like
  • 3 in conversation