DATA Step, Macro, Functions and more

Printing to a new Page using _PAGE_

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 82
Accepted Solution

Printing to a new Page using _PAGE_

Hi, 

 

I am trying to get my simple output to print to a second page a piece of the output. 

I also want to put the page number on each page.

 

Here is my test code:

 

options pagesize=24 linesize=64 nodate pageno=1;

data classlist;
	file "newclasslist.lst";
	retain sumwgts 0;

	set sashelp.class end=last;
	if _n_ = 1 then
	  put @20 "This is my first HEADER"//;

	sumwgts = sumwgts + weight;

	put @5 name @25 age  @30 weight; 
	if last then do;
		put _page_ @15 "Total Summary of Weights on new page";
		put @27 sumwgts;
	end;

run;

But the output is always only written to one page and I never get a page number.  What is it that I am doing wrong? 

Thanks for your suggestions.

 

Nancy


Accepted Solutions
Solution
‎09-29-2017 08:32 AM
Super User
Posts: 11,343

Re: Printing to a new Page using _PAGE_

Posted in reply to SASHunter

I believe that the pagesize, linesize and page number options are only for output sent to the listing destination, Output window.

 

Try:

file "newclasslist.lst" print;

 

Or to see the page effect in SAS you may want to turn on the ods listing and add: File print; to send the text to the output window.

 

Also note from the documentation for _page_:

  If the current output file is printed, _PAGE_ produces an output line that contains the appropriate carriage-control character. _PAGE_ has no effect on a file that is not printed.

So if you don't print the file you are likely not to see the (hopefully inserted) carriage control commands that are supposed to print a new page. However with the advent of ODS and many other output options my plain text with put statements has gotten rusty.

View solution in original post


All Replies
Frequent Contributor
Posts: 149

Re: Printing to a new Page using _PAGE_

Posted in reply to SASHunter

Text-files don't support the concept of "page", so you have to switch to pdf or rtf.

Solution
‎09-29-2017 08:32 AM
Super User
Posts: 11,343

Re: Printing to a new Page using _PAGE_

Posted in reply to SASHunter

I believe that the pagesize, linesize and page number options are only for output sent to the listing destination, Output window.

 

Try:

file "newclasslist.lst" print;

 

Or to see the page effect in SAS you may want to turn on the ods listing and add: File print; to send the text to the output window.

 

Also note from the documentation for _page_:

  If the current output file is printed, _PAGE_ produces an output line that contains the appropriate carriage-control character. _PAGE_ has no effect on a file that is not printed.

So if you don't print the file you are likely not to see the (hopefully inserted) carriage control commands that are supposed to print a new page. However with the advent of ODS and many other output options my plain text with put statements has gotten rusty.

Frequent Contributor
Posts: 82

Re: Printing to a new Page using _PAGE_

[ Edited ]

Thanks - I added PRINT to the file statement.

 

file "newclasslist.lst" print;

 

This worked. 

What about the page number?  Is there a way to get that on there?

 

Thanks so much.

Nancy

Super User
Posts: 11,343

Re: Printing to a new Page using _PAGE_

Posted in reply to SASHunter

As I said, I'm rusty on file print but i think you need to have it as part of Put statemen for the page number, and if your report is going to be multiple pages then you have to provide logic to assign it.

 

Does the output really have to go to a text file? If you use ODS RTF then the page number could be handled with options and by default each table starts on a page.

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 90 views
  • 1 like
  • 3 in conversation