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
Ammonite | Level 13

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
Ammonite | Level 13

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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 1283 views
  • 2 likes
  • 4 in conversation