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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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