DATA Step, Macro, Functions and more

log files

Super Contributor
Posts: 378

log files


Please a want to create one log file for all the treatement ( log_all_trt.txt)  and a log file file for every sub-treatement ( log_treatement_1.txt, log_treatement_2.txt....)


I want this treatement  to be in log file: log_all_trt.txt


proc print data=toto; run;  =                  => I want this treatement  to be in log file : log_treatement_1.txt


proc compare base=t1 comp=t2; run;  => I want this treatement  to be in log file : log_treatement_2.txt


Thank you

Contributor dkb
Posts: 54

Re: log files

Have a look at the documentation for PROC PRINTTO:



Super User
Super User
Posts: 9,599

Re: log files

Well, there are a couple of points in there.  Firstly why do you want to split a log - which is the description of a program run, not data - based on data?  This doesn't make sense.  If you want to create output files on a by group within your data, then do that in proc report.  Now saying that, to split it out into different files, you would need to create a loop over the distinct treatment values:
proc sql;

  create table LOOP as 

  select distinct TRT 

  from   HAVE;


data _null_;

  set loop;

  call execute(cats('%print_data (indat=have,rep_name=report_',trt,',whre=',trt,');');



The above code will create a call to print data macro for each trt.  Something like that can be used to create any output files (e.g. log), however personall I wouldn't associate a log - again which is a run of code - with a data report.

Regular Contributor
Posts: 161

Re: log files



I'm not sure of what platform you are running this on, but if you are using mainframe Z/OS, you might consider having one subtreatment in a generational file and then at the end in a separate JCL step, you might concatenate the gdgs into one dataset through a SyncSort - Copy option and you will have all subtreatments combined to one master dataset. 


The individual generations will be pointing to sub-treatments and the output of the SyncSort  copy will hold the master data that includes all subtreatments. 


If you are running in a Unix platform, you might use a concatenation utility to do what Syncsort does on the mainframe.


Hope this helps...!!!



Kannan Deivasigamani
Ask a Question
Discussion stats
  • 3 replies
  • 1 like
  • 4 in conversation