Published on :
Macro CREATION_INTERNE

Creating and Assigning a Temporary Library

This code is also available in: Deutsch Español Français
Awaiting validation
Attention : This code requires administrator privileges.
The MakeTEMPWORK macro uses the %sysfunc(fileexist) macro function to determine if the 'c:\tempwork' directory exists. If this directory does not exist (rc=0), the macro executes the system command 'md "c:\tempwork"' via %sysexec to create it. This action is specific to Windows operating systems. Finally, it assigns the SAS© library name 'tempwork' to this directory via %sysfunc(libname). This provides a persistent and easily accessible temporary working location within SAS© sessions.
Data Analysis

Type : CREATION_INTERNE


The script does not process external or SASHELP data. It creates a directory on the file system to use as the location for a temporary SAS library.

1 Code Block
Macro Data
Explanation :
This block defines the MakeTEMPWORK macro. It initializes a local variable 'rc' to store the result of the file/directory existence check. If 'c:\tempwork' does not exist, the system command 'md' is executed to create it, which is an administrative operation. Then, the SAS library 'tempwork' is assigned to this new directory. The use of %sysexec makes this script operating system dependent (here Windows) and gives it an administrative role.
Copied!
1%macro MakeTEMPWORK;
2%local rc;
3%let rc=%sysfunc(fileexist("c:\tempwork"));
4%IF &rc=0 %THEN %DO;
5 %sysexec md "c:\tempwork";
6 %let rc=%sysfunc(LIBNAME(tempwork,c:\tempwork));
7%END;
8%mend maketempwork;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.