SAS PGM File Processing
SAS PGM File Processing
*/
*/
*/
pgm
=,
output =,
center,
/* left, center, or right
bottom,
/* top or bottom
2,
/* number of lines from text
= Page PAGEX of PAGEN, /* page number text
!
/* character to use as form feed
*/
*/
*/
*/
*/
*/
*/
*/
);
/* Initialize global system options.
*/
*/
*/
%let strt_col = 1;
/* Initialize system-specific files and options. */
/* Determine the operating system with automatic */
/* macro variable SYSSCP.
*/
%if &sysscp=HP 800 %then
%do;
filename temp1 'potemp1.txt';
filename temp2 'potemp2.txt';
%end;
%else
%if &sysscp=VMS or &sysscp=OS2 or &sysscp=WIN %then
%do;
/* Do not require the user to press enter to */
/* leave the X window brought up by an X
*/
/* statement.
*/
options noxwait;
filename temp1 'potemp1.txt';
filename temp2 'potemp2.txt';
%end;
%else
%if &sysscp=CMS %then
%do;
*/
options formdlim='';
/*
/*
/*
/*
*/
*/
*/
*/
data _null_;
set sashelp.voption;
where optname='LINESIZE' or optname='PAGESIZE';
call symput(optname,setting);
run;
/* Route the output of a dummy PROC PRINT to the */
/* TEMP2 file to generate the next page number. */
proc printto print=temp2 new;
data _temp_;
x=1;
proc print;
options number;
proc printto;
run;
/* Read the first line of output to get the page */
/* number. Store the number in a macro variable. */
data _null_;
infile temp2 truncover;
input record $ 1-200;
call symput('lastpage',trim(left(put(input(reverse
(scan(reverse(record),1)),6.)-1,6.))));
stop;
run;
/* Adjust options.
*/
%let pagesize=%eval(&pagesize+&psadd);
options nodate nonumber ps=&pagesize;
/* Use macro logic to parse the text parameter
/* and create the appropriate DATA step syntax
/* to print the page number.
*/
*/
*/
*/
%let xpos=%index(%nrbquote(&pagetext),PAGEX);
/* If PAGEX occurs at the beginning of the
/* string, substitute this:
*/
*/
*/
*/
*/
*/
data _null_;
infile temp1 length=len truncover eof=eof noprint;
length text $ 200 next_cc $ 10;
retain pagenum;
/* Use the option NOTITLES. Since the input
/* file already has titles, do not repeat
/* printing of the titles.
*/
*/
*/
*/
*/
*/
*/
pagenum=reverse(scan(reverse(record),1));
/*
/*
/*
/*
/*
/*
/*
/*
/*
substr(record,
length(trim(record)) - length(pagenum) +1,
length(pagenum)) = ' ';
/*
/*
/*
/*
*/
*/
*/
*/
if (&psadd gt 0) and
("%upcase(%substr(&topbot,1,1))" eq "T")
then
do; /* Add blank lines to top of page. */
do line_num = 1 to %eval(&psadd);
put #line_num @1 ' ';
end;
end; /* Add blank lines to top of page. */
end;
*/
if _n_ gt 1 then
do;
/* Write regular record back to file.*/
put @1 record $varying200. len @;
if cur_line lt &pagesize then put;
end;
/*
/*
/*
/*
*/
*/
*/
*/
if next_cc eq "&cc&cc&cc&cc&cc&cc&cc&cc&cc&cc"
and pagenum ge 1 then
do;
/* Write page number text. */
/* Use macro logic to set the line and
*/
/* column placement for the page-numbering */
/* text.
*/
/* Place text at top or bottom of the page.*/
/* If T, place text on line 1.
*/
%if %substr(%upcase(&topbot),1,1) eq T %then
%let line=1;
/* Otherwise place text on last line
/* (same as page size).
*/
*/
%else
%let line=&pagesize;
/* Place text at left, center, or right.
*/
*/
text=%unquote(&maketext);
put #&line @&col text;
put _page_;
end;
return;
*/
text=%unquote(&maketext);
put #&line @&col text;
run;
*/
%do;
X 'rm potemp1.txt potemp2.txt';
%end;
%else %if &sysscp=OS2 or &sysscp=WIN %then
%do;
X 'del potemp1.txt';
X 'del potemp2.txt';
%end;
%else %if &sysscp=VMS %then
%do;
X 'del potemp1.txt;*';
X 'del potemp2.txt;*';
%end;
%else %if &sysscp=CMS %then
%do;
X 'erase potemp1 txt a';
X 'erase potemp2 txt a';
%end;
/* No action is needed for &SYSSCP=OS. Files are */
/* deleted automatically when the SAS session
*/
/* ends.
*/
/* Set the page size and page number to the
/* original settings.
options ps=%eval(&pagesize-&psadd)
pageno=%eval(&lastpage+1);
%mend pageof;
*/
*/