DATA Step, Macro, Functions and more

Proc printto not printing entire log

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

Proc printto not printing entire log

Hello!

I am attempting to print a log and list file programmatically using sas 9.3 to an existing script. Currently, my script works fine, and has been used for years, so I am confident in it. However, when I add a printto procedure at the end of this script, my list file is of size 0kb, and I get a log file saved in the correct lcoation, with the following output:

 

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

1970  
1971  /*This last proc print reassigns the output back to the output window*/
1972  proc printto;
1973  run;

 

The problem is that there is a whole bunch more to the log than this (here is a snippet):

1948
1949  proc sort data=testing;
1950  by dno ttno units;
1951

NOTE: There were 2 observations read from the data set WORK.TESTING.
NOTE: The data set WORK.TESTING has 2 observations and 25 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


1952  proc compare base=test.origcheck compare=work.testing /*NOPRINT*/
1953  out=result outbase outcomp outdif /*outnoequal*/;
1954     id ttno units;
1955     title 'Comparing Observations that Have Matching TTNOs';
1956  run;

NOTE: There were 2 observations read from the data set TEST.ORIGCHECK.
NOTE: There were 2 observations read from the data set WORK.TESTING.
NOTE: The data set WORK.RESULT has 6 observations and 27 variables.
NOTE: PROCEDURE COMPARE used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


1957
1958  proc print data=result noobs;
1959     by ttno units;
1960     id ttno units;
1961     title 'The Output Data Set RESULT';
1962  run;

NOTE: There were 6 observations read from the data set WORK.RESULT.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


1963
1964
1965
1966  /*This needs to be an absolute path, not the relative S: drive*/
1967  /*This is saving a copy of the log file and the output to a directory for later varification if need be*/
1968  proc printto log="S:\SS\Update logs\&deal-&update..log" print="S:\SS\Update
1968! logs\&deal-&update..lst" new;
1969  run;

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

 And finally, here is the last bit of the script, where I am attempting to save the log and output:

proc sort data=testing;
by dno ttno units;

proc compare base=test.origcheck compare=work.testing /*NOPRINT*/
out=result outbase outcomp outdif /*outnoequal*/;
   id ttno units;
   title 'Comparing Observations that Have Matching TTNOs';
run;

proc print data=result noobs;
   by ttno units;
   id ttno units;
   title 'The Output Data Set RESULT';
run;



/*This needs to be an absolute path, not the relative S: drive*/
/*This is saving a copy of the log file and the output to a directory for later varification if need be*/
proc printto log="S:\SS\Update logs\&deal-&update..log" print="S:\SS\Update logs\&deal-&update..lst" new; 
run; 

/*This last proc print reassigns the output back to the output window*/
proc printto;
run;

This proc printto seemed really simple at first, but I am at a loss as to what I am doing wrong here? To recap: the files are created, with the correct names and in the correct location, but the list file is empty, and the log file is incomplete. 

 

Any help would be greatly appreciated! 


Accepted Solutions
Solution
‎02-27-2017 01:45 PM
Super User
Posts: 5,083

Re: Proc printto not printing entire log

When you add NEW to PROC PRINTTO, it wipes out the files that you are writing to, and starts with a clean slate.

 

So there should be one PROC PRINTTO (early) that uses NEW.  It should appear BEFORE all the results that you want to redirect to the new locations.  Then all subsequent PROC PRINTTOs should remove NEW.

View solution in original post


All Replies
PROC Star
Posts: 7,363

Re: Proc printto not printing entire log

Not sure if I follow what you've done, but it appears like you are calling proc printo multiple times, rather than calling it once and that only calling it again when you no longer want to capture the log.

 

Art, CEO, AnalystFinder.com

 

Frequent Contributor
Posts: 75

Re: Proc printto not printing entire log

The first proc printto that redirects the log to a file needs to be at the beginning of your program. Then at the end, you redirect it back to the log window with the second proc printto.

Solution
‎02-27-2017 01:45 PM
Super User
Posts: 5,083

Re: Proc printto not printing entire log

When you add NEW to PROC PRINTTO, it wipes out the files that you are writing to, and starts with a clean slate.

 

So there should be one PROC PRINTTO (early) that uses NEW.  It should appear BEFORE all the results that you want to redirect to the new locations.  Then all subsequent PROC PRINTTOs should remove NEW.

Occasional Contributor
Posts: 7

Re: Proc printto not printing entire log

Art, nehalsanghvi, astounding, thank you very much. I somehow misunderstood that while reading the documentation. It seems to work just fine now. Thanks again!

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 238 views
  • 1 like
  • 4 in conversation