DATA Step, Macro, Functions and more

Can I add the userid to the physical work directory name?

Reply
Super Contributor
Posts: 376

Can I add the userid to the physical work directory name?

Hi,

I'm not sure if this post should be here or in SAS Deploy.  Apologies if it should go there instead of here.

We have end users that can't get the concept of a Cartesian product.  In the worst case scenario, our work space gets filled, ETL jobs bomb, and everyone gets angry.

Now, I know I can jump through some hoops to get the owner of a particular physical work directory.  What I'm wondering is if there is some edit I can do to the global configuration file so that the userid that owns the particular SAS process is also a part of the physical name.

IOW, I want to change this:

_TD10996_MYSERVERNAME_

to

_TD10996_USERID_MYSERVERNAME_ 

Can this be done?

Regards,

Scott

Super Contributor
Posts: 376

Re: Can I add the userid to the physical work directory name?

All our work and SAS Util directories are on a specific drive on our server reserved just for that purpose.  This prevents a runaway job from consuming space on a single communal drive.

SAS creates the work sub-directories under this root directory.  Since SAS obviously knows the process ID, and since the process ID has an owner, I was hoping to coax SAS into adding that owner to the generated physical directory name.

Valued Guide
Posts: 632

Re: Can I add the userid to the physical work directory name?

The userid is stored in the automatic macro variable &SYSUSERID.  The data set name becomes something like:

_TD10996_&SYSUSERID._MYSERVERNAME_

Super Contributor
Posts: 376

Re: Can I add the userid to the physical work directory name?

Hi Art,

1) The SAS Work and SAS Util directories are created upon SAS invocation.  I don't believe &sysuserid would be available at that time.

2) If this understanding is incorrect, how would you set this in the system wide configuration file?  I know I can set the -work and -util root directories, but I believe _TD_<processid>_<machinename>_ is baked into SAS.  I was hoping there is some unknown to me option that would allow me to change this naming convention.

I guess there could be some repercussions I need to think about.  For example, it could break the "cleanwork" utility.

Regards,

Scott

Regular Contributor
Posts: 198

Re: Can I add the userid to the physical work directory name?

-SET SASROOT "C:\Program Files\SASHome\SASFoundation\9.3"

examine your configuration file:

!sasroot\nls\en\sasv9.cfg

and find the definition of the various work options and environmental variables (-set):

-SET MYSASFILES "?CSIDL_PERSONAL\My SAS Files\9.3"

-SASUSER "?CSIDL_PERSONAL\My SAS Files\9.3"

-WORK "!TEMP\SAS Temporary Files"

note: ?CSIDL_PERSONAL

is.a API call

solution:

create a personal sasv9.cfg file

and, for your use,

add your UserId into the path name(s)

instructions are on this page:

http://www.sascommunity.org/wiki/Batch_processing_under_Windows

Ron Fehd startup maven

Valued Guide
Posts: 2,175

Re: Can I add the userid to the physical work directory name?

Hi Ron

I really hope you might be able to come along and judge my paper in systems architecture

Configuring foundation SAS Clients easily and with less risk

It seems to invade the teritory your link describes  (I'm sorry) without any reference to your community article.

I hope you'll agree that the new paper is adding some new ideas that are worth hearing.

(it should also become available on Takeout if your schedule is overloaded)

regards

Peter

Regular Contributor
Posts: 198

Re: Can I add the userid to the physical work directory name?

Hi Peter

I would be glad to monitor your paper.

Plz send me an e-mail with your day and time.

Ron.Fehd.macro.maven@gmail.com

Valued Guide
Posts: 2,175

Re: Can I add the userid to the physical work directory name?

like Ron, I have a -WORK that does not define the machine name, but it still appears in the directory name generated by SAS for the work directory that it uses.

although &SYSUSERID is not available BEFORE SAS starts, among environment variables on my machine (default vista business) is USERNAME which looks like the source for &SYSUSERID.

adapting the invocation of SAS to use a -work like

-WORK "!TEMP\SAS Temporary Files\!userName"

achieved exactly what Scott seeks

C:\Users\{user account reduced to 8.3 name}\AppData\Local\Temp\SAS Temporary Files\{full user account ID}\_TD{processID}_{computer name}_

Valued Guide
Posts: 632

Re: Can I add the userid to the physical work directory name?

Teach me not to read the question more closely.  Might there be a system environmental variable that contains that information?  If so then it could be used in Ron's solution, and thus avoiding multiple CFG files.

Regular Contributor
Posts: 198

Re: Can I add the userid to the physical work directory name?

Hi Art

Yes, we can!

Here are some of the Windows Environment Variables that can be fetched with %sysget

%put ComputerName: %sysget(ComputerName);

%put LogOnServer: %sysget(LogOnServer);

%put UserDomain: %sysget(UserDomain);

%put UserName: %sysget(UserName);

%put UserProfile: %sysget(UserProfile);

%Let Evar = temp;

%put &Evar %sysget(&Evar);

%Let Evar = tmp;

%put &Evar %sysget(&Evar);

Ron Fehd  Eeek!-Var maven

refer to

http://www.sascommunity.org/wiki/Category:Environment_Variables

btw: why do we want to assign Unix Evars to Mvars?

Valued Guide
Posts: 2,175

Re: Can I add the userid to the physical work directory name?

Like Ron, I wouldn't know why anyone would want to transfer %sysget(eVar) to &eVar especially when an eVar  might not be valid as a macro variable name

to load all eVars to a table, I use

data env_vars ;

length name $40 value $1024 ;

infile 'set ' device= pipe lrecl=2048 truncover ;

input ; list;

pos = find( _infile_, '=' ) ;

if pos ; * sometimes there is no = ;

name  = substr( _infile_,1, pos-1 ) ;

value = substr( _infile_, pos+1 ) ;

* call symputx( name, value) ;

run;

The LIST statement provides a useful echo of all eVars into the SASlog

uncomment the call symputx() if you want all eVars as macro variables.

peterC

Frequent Contributor
Posts: 120

Re: Can I add the userid to the physical work directory name?

Hi!

Another way to handle this maybe?!

We created another server context (SASAppBatch) for our batches. That server context has its own work (and own file system) which will make batches and other "important" taskt to always run.

Users have no acces to this server context  and are restricted to use SASApp.

We also have other memory settings on this context so that all tasks will run without problems!

//Fredrik

Ask a Question
Discussion stats
  • 11 replies
  • 1190 views
  • 4 likes
  • 5 in conversation