BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
learn_SAS_23
Quartz | Level 8

How to create a log file per session with below command with &sysjobid

 

%let Log_file_name =%sysfunc(compress(%scan(&_program,-1,/)_&sysjobid._%sysfunc(datetime(),b8601dt))).log ;

%let LogOutFile = &Test_path./&Log_file_name.;
filename stplog "&LogOutFile.";
proc printto log=stplog;
run;

 

But it creates log files , with same sysjobid with different times

Test_STP_8628_20210922T173146.log

Test_STP_8628_20210922T173144.log

 

In practice , where my program runs   distributed across servers and runs parallel  in same time , Can  &sysjobid will differ and create different log files ? 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
AllanBowe
Barite | Level 11

The `sysjobid` is the PID and it CAN be the same across multiple sessions.  

Your question is confusing as you ARE creating different log files per process / session due to the use of a timestamp.  To ensure uniqueness though, you might want to use a random number as well, as shown here:  https://core.sasjs.io/mf__uid_8sas_source.html

For even better uniqueness you can use the `uuidgen()` function as shown in this macro:  https://core.sasjs.io/mf__getuniquename_8sas.html

 

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs

View solution in original post

2 REPLIES 2
AllanBowe
Barite | Level 11

The `sysjobid` is the PID and it CAN be the same across multiple sessions.  

Your question is confusing as you ARE creating different log files per process / session due to the use of a timestamp.  To ensure uniqueness though, you might want to use a random number as well, as shown here:  https://core.sasjs.io/mf__uid_8sas_source.html

For even better uniqueness you can use the `uuidgen()` function as shown in this macro:  https://core.sasjs.io/mf__getuniquename_8sas.html

 

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
learn_SAS_23
Quartz | Level 8

Thanks ,We like to create log file per session (i mean when multiple time client programs calls STP , it should create separate STP log file ) , As the log file available from webserver logs are having less details (we can't able to debug what's wrong with STP) . 

 

we can create log file with random number from below links 

 

&today._&now._&sysjobid._%sysevalf(%sysfunc(ranuni(0))*999,CEIL)

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 652 views
  • 2 likes
  • 2 in conversation