Monday, March 26, 2018

Hack 7.8 Getting The Process ID (PID) On UNIX and Linux




SAS Programming Professionals,

Did you know that you can use &SYSJOBID to get the Process ID (PID) of SAS tasks running on UNIX and Linux servers? 

This can be useful for differentiating between multiple SAS sessions you have running on a UNIX or Linux server.  It is also useful when you want to correlate the PID of a particular SAS batch task with UNIX or Linux system performance information. 

Here is an example of using &SYSJOBID that I have coded in many of my SAS/Connect programs:

data _null_;

pid     = &SYSJOBID;

put '******************************************************';
put '*                                                    *';
put '*The Process ID of this SAS/Linux Session is: ' pid '*';
put '*                                                    *';
put '******************************************************';

run;

This code produced the following in the SAS log when running from a PC client to a Linux server:

******************************************************
*                                                    *
* The Process ID of this SAS/Linux Session is: 31037 *
*                                                    *
******************************************************

It might make sense to use &SYSJOBID to document the PID of all of your SAS programs running in UNIX environments.  That way; you will always have that information in your SAS log if you ever need it. 

Best of luck in all your SAS endeavors!

---MMMMIIIIKKKKEEEE
(aka Michael A. Raithel)
Author of the new cult classic for computer programmers:  It Only Hurts When I Hit <ENTER>
Print edition:  http://tinyurl.com/z8bzx2e 
Kindle edition: http://tinyurl.com/zypgqa7 

The hack above is an excerpt from the book:  Did You Know That?  Essential Hacks for Clever SAS Programmers

No comments:

Post a Comment