Hi All,
I have an issue with RTF output, I have a data with 4 columns and rows that are enough to fit in one page,
in proc report assigned cell width for the column1 as 4.5 in and rest 1 in each and looks good on RTF after executing the program, and the problem starts when I rerun the same program on a fresh session then page margins on rtf were narrowed and the last column is moved to second page, but this issue is getting rectified immediately after re-running the code on the same session, Can someone please explain why this is happening while running the prog for the first time on a new session.
Please note: Page margins were assigned as
options leftmargin = rightmargin= topmargin= bottommargin= , on top of the proc report code
and style that I have selected for reporting is styles.rtf
Any help would be very much appreciated and that means a lot to me
Thanks in Advance
Manoj
@s_manoj wrote:
Hi Jim,
Thanks for the prompt replay
I have no autoexec and am running code on SAS EG and below is the piece of code that how I am declaring options statement
ods escapechar='^'; ods _all_ close; ods rtf file = "xxx/xx.rtf" style=styles.rtf headery=0 footery=0 bodytitle_aux; options orientation=landscape; options topmargin=1.15in leftmargin=0.8in rightmargin=0.75in bottommargin=1.15in;
Proc report;
XXX;
XXX;Hope provided would be useful to solve my problem 🙂
It is a good idea to set system options affecting page layout before ODS RTF destination statement. The ODS RTF statement in effect looks at the options set at the time the statement executes to start building page definitions.
That is the reason your second run behaves better. Options set with the OPTION statement persist until reset during a session.
Can you post the code?
And are Option settings the very first thing in the code? Not just the Proc Report, but the first thing SAS encounters. If they are not at the very beginning, I would make them so.
How are you running the code? Display Manager (PC SAS)? Enterprise Guide? SAS Studio? Depending on how you are running the code, you could put the Options statements in your autoexec or in Enterprise Guide in Tools, Options, there is a section on code where one can specify code to be run before running a program, which is a good place for Options statements. If you're running via batch submission, you can use an -initstmt to set the Options before your code runs.
Jim
Hi Jim,
Thanks for the prompt replay
I have no autoexec and am running code on SAS EG and below is the piece of code that how I am declaring options statement
ods escapechar='^';
ods _all_ close;
ods rtf file = "xxx/xx.rtf" style=styles.rtf headery=0 footery=0 bodytitle_aux;
options orientation=landscape;
options topmargin=1.15in leftmargin=0.8in rightmargin=0.75in bottommargin=1.15in;
Proc report;
XXX;
XXX;
Hope provided would be useful to solve my problem 🙂
@s_manoj wrote:
Hi Jim,
Thanks for the prompt replay
I have no autoexec and am running code on SAS EG and below is the piece of code that how I am declaring options statement
ods escapechar='^'; ods _all_ close; ods rtf file = "xxx/xx.rtf" style=styles.rtf headery=0 footery=0 bodytitle_aux; options orientation=landscape; options topmargin=1.15in leftmargin=0.8in rightmargin=0.75in bottommargin=1.15in;
Proc report;
XXX;
XXX;Hope provided would be useful to solve my problem 🙂
It is a good idea to set system options affecting page layout before ODS RTF destination statement. The ODS RTF statement in effect looks at the options set at the time the statement executes to start building page definitions.
That is the reason your second run behaves better. Options set with the OPTION statement persist until reset during a session.
First, move your OPTIONS statements to before your ODS RTF statement. That should take care of your immediate issue. See also what @ballardw is saying in his response.
Second, I bet that you do have an autoexec.sas but that you're just not as aware of it. When you have a moment, run this code:
PROC OPTIONS OPTION=AUTOEXEC;
RUN;
You should see something like this in the log:
SAS (r) Proprietary Software Release 9.4 TS1M6 AUTOEXEC=E:\Program Files\SASHome\SASFoundation\9.4\autoexec.sas Specifies the location of the SAS AUTOEXEC files. NOTE: PROCEDURE OPTIONS used (Total process time): real time 0:00:00.00 cpu time 0:00:00.00 Timestamp October 04, 2020 15:59:19
My autoexec.sas is E:\Program Files\SASHome\SASFoundation\9.4\autoexec.sas.
Now, in EG, autoexec.sas is typically locked down, and you can't touch it.
However, if you go to Tools, Options, SAS Programs, you should be able to check the check-box for "Submit SAS code when the server is connected." To the right of that is an Edit button which will open a little edit window into which you can enter SAS code that will be run every time EG connects to a Server. This is a good place to put standard OPTIONS code. Keep in mind though that these options will apply to all EG sessions if you enter them here.
Jim
Hi, @s_manoj,
That's very odd that the behavior persists even after you've moved your margin statements. Let's check and see if SAS is setting the margin statements the way we think we should.
Can you insert this code just before your ODS RTF statement?
Proc Options Option=(orientation topmargin leftmargin rightmargin bottommargin);
RUN;
The code should look about like this after you insert it:
options orientation=landscape;
options topmargin=1.15in leftmargin=0.8in rightmargin=0.75in bottommargin=1.15in;
Proc Options Option=(orientation topmargin leftmargin rightmargin bottommargin);
RUN;
ods escapechar='^';
ods _all_ close;
ods rtf file = "xxx/xx.rtf" style=styles.rtf headery=0 footery=0 bodytitle_aux;
First you want your option statements.
Second, insert the proc options code I'm suggesting
Third, should be your ODS code.
After you've run the Proc Options, I'd like to see the log file. It should look something like this:
SAS (r) Proprietary Software Release 9.4 TS1M6 ORIENTATION=LANDSCAPE Specifies the paper orientation to use when printing to a printer. TOPMARGIN=1.15 IN Specifies the print margin at the top of the page. LEFTMARGIN=0.8 IN Specifies the print margin for the left side of the page. RIGHTMARGIN=0.75 IN Specifies the print margin for the right side of the page. BOTTOMMARGIN=1.15 IN Specifies the size of the margin at the bottom of a printed page. NOTE: PROCEDURE OPTIONS used (Total process time): real time 0:00:00.00 cpu time 0:00:00.00 Timestamp October 06, 2020 00:02:36
Jim
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!
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.
Ready to level-up your skills? Choose your own adventure.