BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SASHunter
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

4 REPLIES 4
error_prone
Barite | Level 11

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

ballardw
Super User

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.

SASHunter
Obsidian | Level 7

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

ballardw
Super User

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.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 4 replies
  • 2627 views
  • 1 like
  • 3 in conversation