BookmarkSubscribeRSS Feed
Ody
Quartz | Level 8 Ody
Quartz | Level 8

Hello!

I am hoping to get some direction on this. We use SAS Server and every day you log in a new temporary work directy is assigned to you. Is there an easy way to assign this directory to a libname with out manually copying it from the log each mornig into a libname statemnent?

Appreciate any input, thanks!!

13 REPLIES 13
Doc_Duke
Rhodochrosite | Level 12

Actually, the work directories are designed to go away when you end the SAS process.  You should not attempt to reuse them.  Our SAS Admin runs the cleanwork tool to delete any orphan work and utility directories that are left by uses who exit SAS abruptly.

Ody
Quartz | Level 8 Ody
Quartz | Level 8

Thanks for the info Doc@Duke.

I understand they go away after I end my session however I frequently look at the temp tables I'm creating so I was looking for an easier way to create an accessable library instead of copying the temp folder from my log into a libname statement.

Quentin
Super User

Not sure of the benefit (isn't Work 'accessible'?)

You could use:

libname MyWork "%sysfunc(pathname(work))" ;
BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Patrick
Opal | Level 21

The libref is WORK and it is fully accessible to you. Not sure what you're missing. Can you explain?

LinusH
Tourmaline | Level 20

What client are you using?

A situation where I'm using this is when executing code in DI Studio, and then wish to ad-hoc query the intermediate tables, using Enterprise Guide.

Data never sleeps
Patrick
Opal | Level 21

How are you doing this? Copy the work tables to somewhere else? Or actually using the physical path for WORK from the one session as path for a libname statement in another session?

LinusH
Tourmaline | Level 20

The dull answer is I do the same as Ody descibes (and in your second alternative). DI Code editor, libname work list; Copy/paste into EG.

But I would love a neater solution.

Data never sleeps
Patrick
Opal | Level 21

You could as part of the EG session invocation run a bit of code which scans the directories under your root path for WORK for sub-folders (I believe they all start with _TD) and create a concatenated library pointing to all existing folders.

jakarman
Barite | Level 11

You could use Quentins idea.

Get the work directory from the Di session  running:   %put "%sysfunc(pathname(work))" ;    as some user-code.  Then put in EGuide:  libname MyWork "copy/paste" the data.

If you home directory is open for personal files you could save that info from DI in an file at your personal profile directory and activate that in EGuide.  Almost as near getting it fully automated.

As long it is Unix/Windows you only have locking on files, that are the tables. Just avoid  locking issues knowing what you are doing.. Work as usual.    

---->-- ja karman --<-----
Ody
Quartz | Level 8 Ody
Quartz | Level 8

To clarify :

In Server SAS I need to log on every morning (Run > Sign On) which prompts me for the a SAS Session ID and then my network user name and network password. After these are successfully entered I am assigned a temporary Work Library on the SAS Server.

A message like this appears in my log: "Your work directory is J:\SASWORK\_TD26644_B000010455_"

I  do not use the Work folder under the Active Library because every piece of code submitted is done via Remote Submit (Run > Remote Submit) and all temp tables are placed in my temp directory. If I want to view those I need to submit something like: "libname Temp_LIB 'W:\_TD26644_WAPPRIB00001040_';" to create a library in my Active Library.

I'm curious if there is an easy way automate assigning the libname for this temp network directory.

bentleyj1
Quartz | Level 8

As I understant your situation, your SAS server logon/initialization processing assigns a WORK library (e.g.,  J:\SASWORK\_TD26644_B000010455_) and a TEMP library (e.g., W:\_TD26644_WAPPRIB00001040_).  Your programs use the TEMP library instead of the WORK library.  Both are deleted at the end of the SAS session.  (I don't see the point but there must be one.)

Jaap tells how to map the remote (server-side) WORK directory for local (desktop) access but you want to map the TEMP library for local access.  SAS allows you to map any remote library for local access.

Let's say in your signon/connect program you've assigned the remote server the alias 'bigOne' and the TEMP library is named 'temp'.  In the SAS editor, in the local environment issue one of these two commands:

     To use a libref name different from the remote libref when you access it from the local environment use the construct Jaap provided --

          libref remTemp remote server=bigOne slibref=temp;       ** remote is not required but is a visual aid to make it even more obvious that I'm referencing a remote libref. ;

     To use the same libref name as the remote when you access it locally --

          library temp remote server=bigOne;     ** remote is not required. ;

I don't use EG, but to make it run automatically you can add either of these librefs to the bottom of your connect program (if you can modify it) -- just be sure it is after the remote libref TEMP is assigned.

You might want to look at my 2011 SGF paper "Using SAS to Move Data Between Servers".

Ody
Quartz | Level 8 Ody
Quartz | Level 8

All, thanks for the feedback and information!

jakarman
Barite | Level 11

You are telling  something about using SAS-connect. That is behind "run > sign on"  There is a for a server-name  (must have been setup somewhere) and then the user-id password.
The server is obviously a Windows server.  That is offering a lot of opportunities.

The SAS way works also with Unix and Mainframe using the Conenct options.  Slibref SAS/CONNECT(R) 9.4 User's Guide, Second Edition

Setting the conection in asynchronous mode using:  options connectwait=no will let your dms system free for other work. Progress on the other/server side can be followed as "rdisplay"

       "llibname work<serverid-xxx>  server=<serverid> slibref=work ; "   will give you open access to the remote work.

Your <serverid> must be a sas-macro variable containg DNS-address and port of the SAS server (spawner).  serverid-xxx must be a macro-var with some 3 letters as shorten of the server. A libname is limited to a string of 8 chars.    
You can all this having automated at startup as sasscripting.

With Windows when you are knowing the Uncname  of the server and can share data at that location you could use a program rsubmit that and getting it back by sysrput  so you can epand the uncname with that temp-name for a libname.   
Do you have access to that windows sas server at that work using an uncname?

---->-- ja karman --<-----

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 13 replies
  • 3605 views
  • 0 likes
  • 7 in conversation