DATA Step, Macro, Functions and more

How to use CSIDL variables to change the location of SASUSER in Windows

Posts: 36

How to use CSIDL variables to change the location of SASUSER in Windows

I recently made a useful discovery which may help others configure SAS 9.2 on Windows 7 or other versions. My motivation was to move the SASUSER library away from "My Documents" because that location was redirected to a slow network share, which caused occasional errors with the profile and its backup file.

The SAS configuration file SASV9.CFG by default has -SASUSER "?CSIDL_PERSONAL\My SAS Files\9.2". ?CSIDL_PERSONAL resolves to C:\Users\USERID\Documents or wherever that is redirected. I changed it to put it one level higher like so: -SASUSER "?CSIDL_PROFILE\My SAS Files\9.2". You could argue that this is more consistent with common Windows usage, where "My" folders appear directly under the profile home.

It turns out that SAS will understand several of these CSIDL identifiers; I also tried CSIDL_APPDATA. They are deprecated since Windows Vista but while they are still used by SAS, predumably we may still use them. There is a list of variables here: CSIDL (Windows).

These variables may also be used in -SET MYSASFILES and in -SASINITIALFOLDER.

It would be considerate of SAS to document this use of CSIDL variables in the configuration file. For example, !TEMP looks as if it might be a way to refer to environment variables generally, but !OTHER_VAR does not work. If you look with %SYSGET() you will also discover that -SET itself does not expand the CSIDL reference; it happens somewhere else. SAS seems to have embraced and extended the complexity in Windows environment definitions.

Peter Lancashire

Super User
Posts: 10,784

Re: How to use CSIDL variables to change the location of SASUSER in Windows

There is a global option to change default SASUSER library.

libname x v9 'c:\temp';

options user=x ;

Also can change WORK library.

options work=x;

Xia Keshan

Frequent Contributor
Posts: 148

Re: How to use CSIDL variables to change the location of SASUSER in Windows

I confirm Peter's most useful post on all and every points :

1) ?CSIDL_PERSONAL on Win 7 resolves to the location of "My Documents" which is sometimes synchronised with a network share (My Documents Synchronized vs My local Documents)

2) the system synchronisation process might conflict with the SAS session updating SASUSER content, especially SAS profile catalog, SAS registry (itemStore) or Template Store.

3) changing ?CSIDL_PERSONAL with ?CSIDL_PROFILE seems like a functional workaround

4) unfortunately Windows Companion Guide 9.2 doesn't include the slightest reference to ?CSIDL_PERSONAL or %USERPROFILE% dynamic environment variables set up for SASUSER location

5) During the very first steps of SAS Windows launching process (eg Scope = Kernel), for instance when the SASV9.cfg is loaded, as a general rule no system environment variable can be expanded

with the exception of !TEMP  (= %TMP%) or ?CSIDL_<suffix> . It begins further at the Autoexec or Initstmt levels. Furthermore SAS option value based on dynamic resolution (ex.  -OPTION "&macrovar" , OPTION "%sysget(SYSTEMVAR)Smiley Wink might

vary from one option to another . Run proc options with the DEFINE statement to know about it :

Proc Options option=<option name> define;



Option Definition Information for SAS Option SASINITIALFOLDER

    Group= ENVFILES

    Group Description: SAS library and file location information

    Description: Sets SAS's initial working folder. Also changes initial folder of Open and Save

                 As dialog to be current working folder.

    Type: The option value is of type CHARACTER

          Maximum Number of Characters: 260

          Casing: The option value is retained with original casing

          Quotes: If present during "set", start and end quotes are removed

          Parentheses: The option value does not require enclosure within parentheses. If

          present, the parentheses are retained.

          Expansion: Environment variables, within the option value, are not expanded

    When Can Set: Session startup (command line or config) only

    Restricted: Your Site Administrator can restrict modification of this option

    Optsave: Proc Optsave or command Dmoptsave will not save this option

Incidentally, I locked my SASUSER folders more than once because of this and I had to use Sysinternals "Handle" utility to identify the low level SMB/RDP  process involved in the system sync.

Even ProcessExplorer (with local admin privileges) could not display the system process Ids.:smileyplain:

The CSIDLs dynamic variables are supposed to be deprecated with Vista. They are closely linked to the registry keys stored at :

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

Meanwhile, starting in 9.4, SAS recommends using new System environment variables for the SASUSER library:

50713 - The SASUSER default location has changed in the SAS® 9.4 sasv9.cfg file for Windows operatin...

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation