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.
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.
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:
a libref assigned by a LIBNAME statement, a LIBNAME function, or by using the New Library dialog box, with the last assignment taking precedence
a libref assigned by a SAS environment variable
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));
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.