DATA Step, Macro, Functions and more

proc printto print= vs file print statements

Reply
Contributor
Posts: 53

proc printto print= vs file print statements

 Some places I've seen proc printto print= option being used which sends the output to the necessary location and sometimes I've seen FILE PRINT statement being utilized. Are there any rules for when either of these are to be used?

Super User
Posts: 13,939

Re: proc printto print= vs file print statements

Posted in reply to astha8882000

Main difference is duration.

File Print output is for a single data step.

 

Proc Printto output continues sending all of the specified type(s) of output to the destination(s) until canceled.

 

 

Contributor
Posts: 53

Re: proc printto print= vs file print statements

Thank you, that was helpful!

Super User
Posts: 6,933

Re: proc printto print= vs file print statements

[ Edited ]
Posted in reply to astha8882000

PROC PRINTTO controls the output for subsequent procedures, such as reports from PROC FREQ and PROC MEANS.

 

FILE controls messages written by subsequent PUT statements within the same DATA step.  It has no impact on reports from SAS procedures.

 

Now that you've started me thinking, I will have to test what happens when both PROC PRINTTO and a FILE PRINT statement are in effect.  Where will the PUT messages go?

 

************ TEST RESULTS:

 

When both PROC PRINTTO and FILE PRINT are used, the PUT statements in the DATA step write to the PROC PRINTTO destination.

Contributor
Posts: 53

Re: proc printto print= vs file print statements

Posted in reply to Astounding

So in the last scenario that you mentioned, proc printto trumps file print. Great point!

Thank you, that was helpful!

Super User
Posts: 6,933

Re: proc printto print= vs file print statements

Posted in reply to astha8882000

In that last scenario, PROC PRINTTO and FILE PRINT are actually working together.  The FILE statement can still override by specifying a different destination such as:

 

file 'path-to-a-hardcoded-file-name';

 

It's only the use of FILE PRINT that uses the PRINTTO destination.

Ask a Question
Discussion stats
  • 5 replies
  • 99 views
  • 0 likes
  • 3 in conversation