Dear All;
I am trying to import the HTML to RTF output using the following code; however there are 3 problems in here:
1) When I save the output as ods HTML, the web file saved is not looking the same like the one found opened in the sas program after pressing run button!!
2) when I import to rtf using " ods html file="xxxxxx.rtf"; ods html close; the rtf file is totally different from the HTML opened in the sas program.
3) How can I change the width of the row and column lines from being dotted to solid for all the sas output result without specifying certain table?
Thanks in advance.
Yours,
M.Yehia
@MohamedYehia wrote:
1) When I save the output as ods HTML, the web file saved is not looking the same like the one found opened in the sas program after pressing run button!!
Please show some images that illustrate this. Without an image we cannot make any recommendations. Since your data is likely confidential, use sample data from SASHELP to generate a sample report.
2) when I import to rtf using " ods html file="xxxxxx.rtf"; ods html close; the rtf file is totally different from the HTML opened in the sas program.
You say import to RTF, but I assume you mean export and creating some output? So the styles in the RTF is different than HTML? Did you specify a STYLE in your ODS statements? What style is your default? Again, post an example of what this looks like, ideally with the code.
3) How can I change the width of the row and column lines from being dotted to solid for all the sas output result without specifying certain table?
Modify your style and/or template if required. If you're using PROC REPORT you may be able to do it within that procedure.
Basically, yes, you're having issues, but you haven't provided enough information to allow us to answer your questions. Also include your SAS version.
And in addition to Reeza's excellent suggestions, this is incorrect syntax:
ods html file="xxxxxx.rtf"; ods html close;
ODS HTML will NEVER create an RTF file. The correct way to create and RTF file is as shown below:
ods rtf file='xxx.rtf' style=journal;
proc print data=sashelp.class;
run;
ods rtf close;
As Reeza suggests, we need to have a better explanation and a better example of the actual code you've tried. What you describe should NOT work.
cynthia
Hi Cynthia and Reeza,
Thanks a lot for you reply. I am sorry for not attaching pics for clarification. Reeza you are right about export not import. However Cynthia, you can create an rtf file using ODS HTML and I wil show you the pics of what I did.
Picture named "Untitled1" is what I got using ODS HTML"file path.rtf"; ODS HTML close;
Pic "Untitled2" is what I got after saving the ODS HTML as a webpage.
pic "Untitled3" is what I want to make my output.rtf looks like; "as you can see the row lines or borders of the tables inside are bold and solid, however the column lines or borders are the same as the table border.
pic "Untitled4" is what I got on the SAS Result window. Please check the difference between pic 3 (The One I want to do) with the pic 4.
Thanks a lot for your kind assistance.
Yours,
M.Yehia
Hi:
I apologize for not being thorough in my explanation. ODS HTML creates an ASCII text file that contains HTML markup language tags. No matter what file extension you use, ODS HTML will ALWAYS write HTML strings INSIDE the file. You can prove this to yourself as shown in the screen shot below:
Note how I used ODS HTML to mimic your process and I named the file with the .RTF file extension. ODS HTML did NOT create a conforming RTF file. ODS HTML created a file with HTML tags inside -- you can open the resulting RTF file with NOTEPAD and see the HTML strings and NOT the correct RTF strings.
However, if you use the correct destination ODS RTF, as shown in the second screen shot below:
You can see that the RTF control strings are correctly created when the ODS RTF destination is used.
I do not see any purpose in using ODS HTML to try to create something that you give the extension of RTF because it is NOT RTF commands in the file.
cynthia
Hi,
Now, I understand your point of view and you are right about that. However, even the ODS HTML output is not the same as the one in PDF "Untitled3". That's why I want to know the syntax to write to be able to get the column and row borders as shown in PDF "Untitled3"?.
Yours,
M.Yehia
@MohamedYehia wrote:
Hi,
Now, I understand your point of view and you are right about that. However, even the ODS HTML output is not the same as the one in PDF "Untitled3". That's why I want to know the syntax to write to be able to get the column and row borders as shown in PDF "Untitled3"?.
Yours,
M.Yehia
You should show the exact code used to create any of those files.
One thing that changes line types and such is the active ods style. The RTF and PDF desitnations will use a different default style if you do not specify one on the ODS RTF or ODS PDF statement.
Which version of SAS are you working with? The available SAS supplied styles vary between releases. I do not see a style in 9.4.4 that duplicates the appearance of your 'untitled3' so the table may have been made with a custom style or style overrides in a procedure.
There is also a chance that what we see isn't what you see from your HTML after you run it through a converter to PDF.
If you are generating your output with the basic report procedures Proc Print, Report or Tabulate you can provide style overrides for cell color background and borders.
Hi,
I am working with SAS 9.1.3. I just want to know the syntax that specifies the border width of columns and rows.
Thanks
In the report procedures you would be specifying borderwidth in a style overide, there are some differences in how this looks depending on the procedure. In Proc Report it would be in a define block, in proc print a style element for specific variables and in proc tabulate either in a classlev, keywork or statistic description in the middle of a table definition.
And row or column headers usually involve something different than cells in the body of an output.
proc print data=sashelp.class noobs;
var name /style=[borderwidth=4pt ];
var sex /style=[borderwidth=1pt ];
run;
You may also have the option of bordertopwidth borderbottomwidth borderrightwidth and borderleftwidth, and color and style. But I don't have 9.1.3 references and there have been a lot of changes since then.
Note that some options to not apply to all ODS destinations with PDF being a common exception but HTML and RTF are usually pretty compatible.
I have just found the code required to change the style of all the sas output. Below is the code. However; I wonder why when I change the cell spacing, it will be changed only in the SAS result window and not in the saved HTML file!!.
proc template;
define style Styles.Custom;
parent = Styles.default;
replace fonts /
'TitleFont' = ("Verdana",16pt,Bold Italic) /* Titles from TITLE statements */
'TitleFont2' = ("Verdana",14pt,Bold Italic) /* Proc titles ("The XX Procedure")*/
'StrongFont' = ("Verdana",14pt,Bold)
'EmphasisFont' = ("Times Roman",12pt,Italic bold)
'headingEmphasisFont' = ("Times Roman",11pt,Bold Italic)
'headingFont' = ("Verdana",14pt,Bold) /* Table column and row headings */
'docFont' = ("Verdana",12pt) /* Data in table cells */
'footFont' = ("Times Roman",13pt) /* Footnotes from FOOTNOTE statements */
'FixedEmphasisFont' = ("Courier",9pt,Italic)
'FixedStrongFont' = ("Courier",9pt,Bold)
'FixedHeadingFont' = ("Courier",9pt,Bold)
'BatchFixedFont' = ("Courier",6.7pt)
'FixedFont' = ("Courier",9pt);
replace Table from Output /
frame = box /* outside borders: void, box, above/below, vsides/hsides, lhs/rhs */
rules = all /* internal borders: none, all, cols, rows, groups */
cellpadding = 10pt
cellspacing = 1pt
borderwidth = 4pt;
end;
run;
Was the style Custom actually created? (no errors in log)
Did you specify using your custom style? ods html style=styles.custom <other ods html options>;
Did you rerun code and overwrite the old file? ods html style=styles.custom path='C:\path' body='file.html'; or similar
As I mentioned, show the code you are using to create the output. if there are unexpected behaviors then include the log. Paste them into a codebox opened using the forum {i} menu icon as the message windows can reformat text.
Hi:
Your style template inherits from STYLES.DEFAULT which was originally defined as an HTML style, meant to be opened in a browser. The RTF style inherits from STYLES.DEFAULT, but changes those style elements and attributes that are best in HTML to those settings that are best in RTF, when opened in Word.
I would never expect an HTML-style to work in RTF the same way as it does in HTML. For one thing, in HTML, sometimes, the border specifications that work in RTF might not work in HTML. For example, if I specify a border width of 15 PX for HTML, I might actually see very wide borders, but the exact same code used in RTF or PDF destinations does NOT generate the same results.
As an experiment, run this code and review the results to see how each destination treated the exact same style settings differently.
ods pdf file='c:\temp\diffborders.pdf';
ods rtf file='c:\temp\diffborders.rtf';
ods html file='c:\temp\diffborders.html';
proc report data=sashelp.class(obs=3)
style(report)={bordertopcolor=pink borderbottomcolor=cyan borderrightcolor=red borderleftcolor=purple
bordertopwidth=15px borderbottomwidth=15px borderrightwidth=15px borderleftwidth=15px};
column name age height;
run;
ods _all_ close;
You will notice that the thickness specified in HTML is NOT used by RTF and PDF. So a style template needs to be designed to work for RTF, using the RTF destination, not using the HTML destination and your method of making an HTML file and just naming it RTF is not going to make the fundamental differences change.
So before you wonder why your somewhat convoluted process does not result in the same borders and border widths being used, it might be helpful to understand how the destinations work first. Your assumption, for example that whatever works in HTML should work for RTF is not always true.
cynthia
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: