SASInitialFolder

Reply
Contributor
Posts: 29

SASInitialFolder

How do I use SASInitialFolder with a multiuser set up?

I have tried -SASINITIALFOLDER "D:\SAS\users\&sysuserid" and -SASINITIALFOLDER "D:\SAS\users\!USERNAME" to no avail.

I receive

WARNING: Could not change working folder to "D:\SAS\users\\&sysuserid".  -SASINITIALFOLDER

         folder ignored.

Super User
Posts: 10,538

Re: SASInitialFolder

This is one of the options that has to be set at invocation, basically that means in the configuration file. It can't be changed after starting SAS.

There may be another clue in the Warning because there are 2 \ preceding &sysuserid.

Contributor
Posts: 29

Re: SASInitialFolder

I am trying to set in configuration file to be run at execution. I suppose I should have flipped the order of attempts I posted. I initially used "D:\SAS\users\!USERNAME" and receive the same error. !USERNAME is used in config for work and sasuser (part of invocation) already but does not work for sasinitialfolder (or -set sasautos)

Trusted Advisor
Posts: 1,630

Re: SASInitialFolder

This must go in the CONFIG file, and I don't believe you can use SAS Macro variables in the CONFIG file.

You could hard code the !USERNAME and then create separate CONFIG Files for each user. Then create SAS shortcut on the desktop (or elsewhere) for each user, pointing to the proper CONFIG file, so use Tom would double-click on the proper SAS icon for Tom; and user David would double-click on the proepr SAS icon for David; etc.

Contributor
Posts: 29

Re: SASInitialFolder

I fully understand that PaigeMiller but that is outside the scope of my question.

If /you know/ the answer is 'you can't do that' feel free to say I can't.

However, it is odd that I can use windows environment variables in sasv9 for -work and -sasuser but not -sasinitialfolder

Valued Guide
Posts: 3,208

Re: SASInitialFolder

The sas initialfolder is a Windows only and only for for sasbase/foundation not for a bi/di or a solution.

Check this prerequisite!

When you have a sas/base foundation approach there is a usermods configure you can use for your modifications.

In this all windows environment vars and sas config ones may be used with the exclamation point ! . This is different to sas program coding where you use the and & sign.

There are several windows options normally not made visible.

This is along the usage of roaming profiles.

When you are using a bi/di approach the default setting of the current dir is in a failure at the app level not the home.

---->-- ja karman --<-----
Valued Guide
Posts: 3,208

Re: SASInitialFolder

Use the Windows environ tears with an exclamation point and it will work with a sas/base foundation installation

When you have a bi/di server approach the modifications are needed at the appserver level. The default of sas is having a faulty setting

---->-- ja karman --<-----
Contributor
Posts: 29

Re: SASInitialFolder

Thank you jaap. I must have typoed or something but -SASINITIALFOLDER "!SASUSERROOT\!USERNAME" does work (have set sasuserroot as well)

Contributor
Posts: 29

Re: SASInitialFolder

Jaap can I ask the same question about -SET SASAUTOS?

-SET SASAUTOS (

"!SASUSERROOT\!USERNAME\automacros"

folder and macro does exist and

WARNING:  D:\SAS\users\\!USERNAME\automacros is missing from concatenation.

-SET SASAUTOS (

"!SASUSERROOT\COMMON\automacros"

Does work (testing user defined init variables work)

Valued Guide
Posts: 3,208

Re: SASInitialFolder

You have used twice the exclamation point usage on the same line. That could be the issue as at some older versions it was allowed only once on a line.

No I did not invent that also came across that.

As there are windows variables fully covering the needs I did not have an issue with that.

But remember sas initialfolder only works with using the dbms classic usage. Not wit eguide di and all others.

---->-- ja karman --<-----
Contributor
Posts: 29

Re: SASInitialFolder

-SET SASAUTOS (

  "D:\SAS\users\!USERNAME\automacros"

Also does not work

WARNING:  D:\SAS\users\!USERNAME\automacros is missing from concatenation.

Contributor
Posts: 29

Re: SASInitialFolder

Also -SASINITIALFOLDER "D:\SAS\users\!USERNAME" does not work. Creates a !USERNAME folder.

Regular Contributor
Posts: 200

Re: SASInitialFolder

The bang or exclamation point :smileyalert: is the prefix to a (Windows) environment variable (e-var).

At the Windows DOS prompt you can examine what is set on your computer with the DOS command 'set'

cSmiley Embarassed set

This will list all the Windows environment variables.

You can list all e-vars with a prefix with this syntax:

c:\set user

On my Win.XP there is an e-var UserProfile whose value is

C:\Documents_and_Settings\Ronald

Note: I have replaced spaces in the above value with hard-spaces, i.e. an underline (_)

I can use this in a sasv9.cfg file like this

-sasinitialfolder "!userprofile"

Double quotes are needed because the value contains spaces.

If the value does not contain spaces then this will work

-sasinitialfolder !userprofile

I do not have a reference, just my experience for these empirical facts.

* You cannot use two e-var references in a line.

* e-var references must be first item in a folder-specification

This follows my first empirical note, you cannot use this:

-<optionname> folder\!evar

this is the syntax to create environment variables in a sas configuration file

-set evar 'value'

single and double quotes can be used

lists can be assigned

-set evarlist ('value.1' 'value.2')

Here is another empirical oddity.

* length of Windows environment variable names is 14

Ron Fehd  configuration file and syntax maven

Contributor
Posts: 29

Re: SASInitialFolder

Ya. Have seen that lots of things are YRMV. For example,

-SET SASUSERROOT "D:\SAS\users\"

-SET MYSASFILES "!SASUSERROOT\!USERNAME"

works

-SET SASUSERROOT "D:\SAS\users\"

-SET MYSASFILES "D:\SAS\users\\!USERNAME"

does not work

-SASINITIALFOLDER "D:\SAS\users\!USERNAME"


does not work


I really hate inconsistent logic in coding/config/etc.

Super User
Super User
Posts: 6,502

Re: SASInitialFolder

Did you try using the Windows environment expansion syntax instead of the SAS invented ! notation?

-SASINITIALFOLDER "D:\SAS\Users\%USERNAME%"

Ask a Question
Discussion stats
  • 14 replies
  • 853 views
  • 4 likes
  • 6 in conversation