Tagprinting

Errors When Using Page X of Y in SAS ODS pdf Statements

SAS ODSI ran across a familiar error this week, so I figured I might as well finally document it on this blog. My organization primarily uses Lexmark printers, and print drivers are included in the standard PC image. Apparently the drivers installed on the standard image are not considered “valid printer drivers” by SAS, because we generate errors in our PC SAS 9.3 logs when we attempt to create a .pdf file using the SAS ODS pdf destination. For example, if my colleagues submit a statement such as:

ods escapechar = '^';
ods pdf file="output.pdf"; 
proc print data=sashelp.class(obs=5); 
footnote j=r 'page ^{thispage} of ^{lastpage}';
run; 
ods pdf close;

Errors will be generated:

ERROR: There is no currently selected printer driver.  Use Print Setup to select an installed printer driver.

ERROR: Internal error trying to set up “page i of n” processing.  Could be caused by out of memory, out of disk space, or internal coding error. Check for other error messages above indicating probable user error or resource constraints; if there are none, or if they make no sense, please report this message and provide a test program to SAS Institute. Output will continue without PAGEOF support.

A colleague had a newly refreshed PC, so I installed PC SAS and all of the EBI developer tools for him. I did not perform any customization to his SAS environment; I each developer is different so I let them tweak their own settings. It appears that I will need to begin to at least edit the sasv9.cfg file for all new developer SAS installations to include the following to prevent the errors:

-uprint
-uprintmenuswitch

In our case the sasv9.cfg file is located at
C:\Program Files\SASHome\x86\SASFoundation\9.3\nls\en\sasv9.cfg. The options we have to add turn on Universal Printing. What is that? Here is how SAS describes it:

What Is Universal Printing?

Universal Printing is a printing system that provides both interactive and batch printing capabilities to SAS applications and procedures on all operating environments that are supported by SAS. Universal Printing enables you to define printers and print previewers, and to control most printing options as your output is created. In addition to sending output to a printer, you can print to external files.

Windows Specifics: By default, the Windows operating environment uses Windows printing and not Universal Printing. For more information about using Universal Printing under Windows, see Setting Up the Universal Printing Interface and the Default Printing Environment.

SAS routes all printing through Universal Printing services. All Universal Printing features are controlled by system options, thereby enabling you to control many print features, even in batch mode. For more information about these system options, see System Options That Control Universal Printing.

Note: Before the introduction of Universal Printing, SAS supported a utility for print jobs known as Forms. Forms printing is still available if you select Filethen selectPrint Setup from the menu, then check the Use Forms check box. This turns off Universal Printing menus and functionality. For more information, see Forms Printing.

Setting Up the Universal Printing Interface and the Default Printing Environment

Universal Printing is enabled when SAS starts in the UNIX or z/OS operating environment. Under Windows, Windows printing is enabled when SAS starts. To use Universal Printing in Windows, you must set the UNIVERSALPRINT system option to enable the Universal Printing menus and dialog boxes, and to set up the printing defaults. This option can be set only in a SAS configuration file or at start-up. You cannot enable or disable Universal Printing menus and dialog boxes after SAS starts.

Windows Specifics: In the Windows operating environment, include the following system option when you start SAS:

-uprint

UPRINT is an alias for the UNIVERSALPRINT system option.

Note: When you use the PRINTERPATH= system option to specify a printer, the print job is controlled by Universal Printing. To return to Windows printing, set the PRINTERPATH= system option to a null string: PRINTERPATH=”.

We never saw these errors when developing in the Solaris or AIX environment because Universal Printing is turned on by default in those environments.

Email this to someoneTweet about this on TwitterShare on LinkedInPin on PinterestShare on Google+Share on FacebookPrint this page

Clearing a Print Queue Backlog in AIX

We have a z/OS application that streams data down to our AIX-based POWER7 server. On the server, we have a SAS application that turns the stream into a PDF document and sends the PDF to a printer which is specified by the user on the z/OS application. Many of the printers that are assigned to the z/OS application have been decommissioned, yet the end users continue to send print jobs to them. This dynamic requires us to do quarterly housekeeping on the z/OS and AIX environments to keep active printers current.

During the quarter, however, end users will inadvertently send print jobs to printers that don’t exist anymore, so the AIX server creates a backlog of orphaned print jobs over time. Below are the steps to clean up the backlog. I originally found these steps on IBM’s web site.

You must be logged in as root or as a user with sudo access.

  1. If possible, let all current print jobs finish printing or cancel them. To cancel a print job, issue the lpstat command to get the print job number, then use the enq command to cancel the print job.

    enq -x JobNumber

    The lpstat command displays information about the current status of the line printer. The enq command enqueues a file.

  2. Issue the following command to stop qdaemon:

    stopsrc -s qdaemon

  3. Issue the following commands to verify that qdaemon did not fork other processes:

    ps -ef | grep qdaemon
    ps -ef | grep pio

    The ps command shows the current status of processes. The grep command searches a file for a pattern. If you get one line back from each of the above grep commands, skip step 4 and go to step 5. If you get more than one line, go to step 5.

  4. If other qdaemons or pios were returned by the ps -ef command, kill these processes by issuing the following command with each process ID:

    kill -9 pid

    The following example shows a qdaemon returned by ps -ef. The process ID is 3357.

    root 3357 2288 0 13:32:21 - 0:04 dtterm

    To kill this process ID, enter kill -9 3357 at the command line.

  5. Change the directory as follows:

    cd /var/spool/lpd/qdir

  6. Issue a pwd command to verify that you are in the proper directory. Then, remove all files in this directory using the rm command:

    rm *

    The pwd command writes to standard output the full path name of your current directory (from the root directory). The rm command removes the entries for the specified file or files from a directory.

  7. Change the directory again:

    cd /var/spool/lpd/stat

  8. Issue a pwd command to verify that you are in the proper directory. Then, remove all files in this directory:

    rm *

  9. Change the directory again:

    cd /var/spool/qdaemon

  10. Issue a pwd command to verify that you are in the proper directory. Then, remove all files in this directory:

    rm *

  11. Follow this step if you are having trouble with the remote queue or lpd. Change the directory:

    cd /var/spool/lpd

  12. Issue a pwd to verify that you are in the proper directory. Then, remove all files in this directory using the rm command:

    rm *

    Note: The rm command will not remove the subdirectories.

  13. Start qdaemon:

    startsrc -s qdaemon

Email this to someoneTweet about this on TwitterShare on LinkedInPin on PinterestShare on Google+Share on FacebookPrint this page

SAS ODS: {thispage} and {lastpage} and PDF Output

saslogo

When developing new reports, we typically give the end users a choice of output formats to choose from.  The SAS Output Delivery System (ODS) provides a versatile framework to transform the results of SAS procedures into consistent, high quality reports in formats that are widely used by information consumers: HTML (HyperText Markup Language), PDF (Portable Document Format), RTF (Rich Text Format), Microsoft Excel, and others.  The majority of our reports (run as stored processes surfaced in the SAS Information Delivery Portal) contain tabular output, which is generally displayed to a user in HTML format with the option to download that data as a Microsoft Excel spreadsheet.

Some reports are designed to be formatted as a document, and include large amounts of ODS text, tables, and graphs.  We generally use ODS functions such as {thispage}, {pageof}, or {lastpage} to display the page number or number of pages in the document.  When using RTF as our ODS destination, the creation of a Microsoft Word document could not be easier.  We did run into one issue when using the PDF output destination, however.  Due to the configuration of printer drivers on our computer systems, the page numbers were not showing up in our documents, because SAS was unable to determine a default page size and margins.  We contacted SAS Technical Support and they pointed us to SAS Problem Note 31703 as a possible fix.  Tech Support solved our problem – we added the –uprint and –uprintmenuswitch options to our autoexec.sas configuration file and restarted our object spawners and our PDF documents included page numbers!

Want to know more about the SAS Output Delivery System?  Go to the Base SAS ODS Focus Area or download the Output Delivery System Tip Sheet.

Email this to someoneTweet about this on TwitterShare on LinkedInPin on PinterestShare on Google+Share on FacebookPrint this page

© 2017 Technoleros

Theme by Anders NorénUp ↑