BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Nasser_DRMCP
Lapis Lazuli | Level 10

Hello,

I have 3 programs. one main program that launch two sub programs. I would like 3 log files.

I would like to obtain this 4 notes below inside the log of the main prog

"The subprog 1 is started"

"The subprog 1 is completed"

"The subprog 2 is started"

"The subprog 2 is completed"

 

so this is what I done but it does not work :

in the main prog :

PROC PRINTTO log='$GRPLOGS/mainprog.log' new;
RUN;

%include subprog1.sas  

%include subprog2.sas  

proc printto;

run ;

 

in the subprog1 

%PUT the prog 1 is started ;

PROC PRINTTO LOG='$GRPLOGS/subprog1' NEW;
RUN;

%PUT the prog 1 is completed ;

proc printto ;

run ;

 

and the same for the subprog2 ;

 

many thanks a lot in advance

kind regards

Nasser

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

Have you tried using a data null step inside the sub programs?

 

/* After proc printto */
data _null_;
  file "$GRPSLOGS/mainprog.log" mod;
  put "The subprog 1 started";
run;

The end-message can be written by a similar step.

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

@Nasser_DRMCP wrote:

Hello,

I have 3 programs. one main program that launch two sub programs. I would like 3 log files.

I would like to obtain this 4 notes below inside the log of the main prog

"The subprog 1 is started"

"The subprog 1 is completed"

"The subprog 2 is started"

"The subprog 2 is completed"

 

so this is what I done but it does not work :


 

 

What doesn't work? HINT: never tell us that something doesn't work and then not explain further. If there are errors in the log, show us the entire log for this section of code. If the output is wrong, show us the incorrect output and then tell us what you would like to see.

--
Paige Miller
Nasser_DRMCP
Lapis Lazuli | Level 10

Hello PaigeMiller

 

thanks for you quick respons 

sorry for forgetting explanation on what does not work.

My problem is that the subprog 1 writes ""The subprog 1 is started" inside the log file of the main prog

but "The subprog 1 is completed" is not writing 

regards

Nasser

PaigeMiller
Diamond | Level 26

@Nasser_DRMCP wrote:

 

My problem is that the subprog 1 writes ""The subprog 1 is started" inside the log file of the main prog

but "The subprog 1 is completed" is not writing 


Not writing it at all, or not writing it in the proper place (which is in the main program)?

--
Paige Miller
Nasser_DRMCP
Lapis Lazuli | Level 10

Not writing it at all, neithor in the log of the main prog, nor in the log of the sub prg 1

PaigeMiller
Diamond | Level 26

Show me the log for your code, from say 10 lines above to 10 lines below this:

 

%PUT the prog 1 is completed ;
--
Paige Miller
Nasser_DRMCP
Lapis Lazuli | Level 10
/* below : MAINPROG */

/* create the log of the mainprog */
PROC PRINTTO log='$GRPLOGS/MAINPROG.log' new;
RUN;

%INCLUDE '$GRPSBSAS/SUIVIS/CLIENT/RECOUV/CESSION/SUBPROG1.sas';                    


/*close the log of the main prog */
PROC PRINTTO;
RUN;



/* BELOW the SUBPROG1 */
%PUT the SUBPROG1 is started ;

/* create the log of the SUBPROG1 */
PROC PRINTTO LOG="$GRPLOGS/SUBPROG1.log" NEW;
RUN;

%put this is the SUBPROG1 ;

/* close the log of the SUBPROG1 */
PROC PRINTTO;
RUN;

%PUT the SUBPROG1 is completed ;

Hello PaigeMiller

please find the code of the prog main and sub prog 1.

and this is below the entire log of the main prog. as you can notice, "started" appears but "completed" does not  !

many Thanks .

main log==>

NOTE: PROCEDURE PRINTTO used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

23
24
25 %INCLUDE '$GRPSBSAS/SUIVIS/CLIENT/RECOUV/CESSION/SUBPROG1.sas';
NOTE: %INCLUDE (level 1) file $GRPSBSAS/SUIVIS/CLIENT/RECOUV/CESSION/SUBPROG1.sas is file
/data/crea/creapil/sbsas/SUIVIS/CLIENT/RECOUV/CESSION/SUBPROG1.sas.
26 +
27 +%PUT the SUBPROG1 is started ;
the SUBPROG1 is started
28 +
29 +/* create the log of the SUBPROG1 */
30 +PROC PRINTTO LOG="$GRPLOGS/SUBPROG1.log" NEW;
31 +RUN;

 

andreas_lds
Jade | Level 19

Have you tried using a data null step inside the sub programs?

 

/* After proc printto */
data _null_;
  file "$GRPSLOGS/mainprog.log" mod;
  put "The subprog 1 started";
run;

The end-message can be written by a similar step.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 7 replies
  • 1667 views
  • 0 likes
  • 3 in conversation