BookmarkSubscribeRSS Feed
Eileen1496
Obsidian | Level 7

Hi all,

 

I have been using SAS/CONNECT to run my code more efficiently using multiple cores of my CPUs. However one thing not clear to me is how to make each task inherit the work(temporary) folder? 

 

One block of my code is as follows. I can use libname to indicate different folders on my disk, but I cannot do so with temporary folder. What should I do?

/* Prosess 1 */
signon task1;
rsubmit task11 wait=no;

libname temp_e "E:\data\temp"; 

proc sql threads;
    create table uid_11 as
    select *,
           coalesce(enddate, '2022-12-31') as imputed_enddate,
           case when missing(enddate) then 1 else 0 end as miss_end
    from temp_e.uid_11;
quit;


endrsubmit;
9 REPLIES 9
Tom
Super User Tom
Super User

Use the INHERITLIB=  option of the SIGNON statement.

 

For example if you wanted each "task" to have access to the TEMP libref the pattern would look like:

libname temp 'some directory';
signon task1 inheritlib=(temp);
rsubmit task11 wait=no;
proc sql threads;
    create table uid_11 as
    select *,
           coalesce(enddate, '2022-12-31') as imputed_enddate,
           case when missing(enddate) then 1 else 0 end as miss_end
    from temp_e.uid_11;
quit;
endrsubmit;
Eileen1496
Obsidian | Level 7

Hi Tom,

 

I did tried this way, but it can only inherit non-temporary folder I built myself, the temporary folder cannot be inherited. The detail is:

I set the following folder as my work library (the temporary one): E:\data\work

and using your code i did this: 

libname work 'E:\data\work';
options sascmd="sas";
options CPUCOUNT= 45;
/* Current datetime */
%let _start_dt = %sysfunc(datetime());

/* prosess 10 */
signon task10 inheritlib=(work);
rsubmit task10 wait=no;
....

but SAS told me:

ERROR: The SAS system library WORK may not be reassigned.
ERROR: Error in the LIBNAME statement.

 

The above code works for all other non-temporary folder.

Just to be clear: by temporary folder/work folder here, i mean the one where the data is stored if you don't specify libname in

libname.dataname

and all files in this folder will be deleted after every sas session

Tom
Super User Tom
Super User

If you don't tell SIGNON what name to use for the libref on the remote session it will try to use the same name it has on the local session.  But there is already a libref WORK on the remote session. So tell it to use a different name.

signon task10 inheritlib=(work=_work);

 

AhmedAl_Attar
Rhodochrosite | Level 12

Hi @Eileen1496 

This is what worked for me

%syslput g_pWorkPath = %sysfunc(PATHNAME(WORK)) / remote=<taskx>;
Rsubmit taskx;
   LIBNAME pWork "&g_pWorkPath";
    /* To save into the parent's WORK library, use the pWork LibRef */
EndRsubmit;
Eileen1496
Obsidian | Level 7

HI Ahmed,

 

can you tell me which part i should replace? and what should I replace it with?

I tried the following:

signon task10 inheritlib=(raw, clean);
%syslput g_pWorkPath = %sysfunc(PATHNAME(WORK)) / remote=task10;
rsubmit task10 wait=no;
LIBNAME pWork "&g_pWorkPath";

but it tells me:

ERROR: Library , has not been assigned in the local session therefore it cannot be inherited by
the remote session.
ERROR: Remote signon to TASK10 canceled.
ERROR: A link must be established by executing the SIGNON command before you can communicate
with TASK10.
114 %syslput g_pWorkPath = %sysfunc(PATHNAME(WORK)) / remote=task10;
115 rsubmit task10 wait=no;
ERROR: A link must be established by executing the SIGNON command before you can communicate
with TASK10.
ERROR: Remote submit to TASK10 canceled.
AhmedAl_Attar
Rhodochrosite | Level 12

Hi @Eileen1496 

Remove the comma (,) from the inheritlib=

signon task10 inheritlib=(raw clean);
Eileen1496
Obsidian | Level 7

I get rid of the comma and run again, but it still says:

ERROR: A communication subsystem partner link setup request failure has occurred.
ERROR: Cannot locate TCP host 'TASK10'.
ERROR: Remote signon to TASK10 canceled.
ERROR: A link must be established by executing the SIGNON command before you can communicate
with TASK10.
SASKiwi
PROC Star

Please post your complete SAS log, not just the errors, so we can see the code you are running.

 

It looks like you haven't defined TASK10 anywhere.

 

I'd expect to see a %LET statement defining it like so - note replace MySASComputeServer with the actual name of your server:

%let task10 = MySASComputerServer;

signon task10;
SASKiwi
PROC Star

I suggest it would be dangerous to share SAS WORK libraries between SAS/CONNECT SAS session. You would be better off setting up a dedicated permanent SAS library for sharing data between SAS sessions and just copy the WORK datasets you need to share into that library.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 9 replies
  • 478 views
  • 2 likes
  • 4 in conversation