data _NULL_;
file print;
if e then put 'No observations';
set TableA end=e;
put 'here is the table A';
stop;
run;
How do I change font size and color for the quotes in the put statement?
In general you might want to use graphics options on a title statement.
However, ODS output can be modified with inline styling directives introduced via the escapechar.
ods pdf file='want.pdf';
ods escapechar = '^';
* standard options for title statement;
title color=white bcolor=blue bold italic height=36pt "Title for want";
data _null_;
file print;
put '^{style [fontsize=24pt color=Red]Hi}'; * inline styling;
run;
ods pdf close;
Related
I am creating a RTF file using SAS ODS. When I add a text using "ODS TEXT", the column headers of a table are not repeating in next page but comes only at the start of the table.
When I remove the "ODS TEXT", I get columns names in all pages. Since I need a text above the table (not in header/title), can you suggest a solution?
data chk;
set sashelp.class;
output; output;
run;
ods rtf file = "xx\check.rtf";
ods escapechar = '^';
title " ";
ods text="ods text";
proc report nowd data=chk ;
run;
ods rtf close;
I am trying to create a table of contents with hyperlink in Ods pdf.My requirements are I want a table of contents with page no as well as hyperlink also.
I have try two methods.
I have created table of contents with datalines in which I have used ods pdf anchor to create hyperlink in pdf report but I am not getting page no.
I have used ods proclabel to create table of contents in that I am getting page no but not getting hyperlink
Here is a sample of 2). ODS PDF CONTENTS creates a TOC with entries that are the bookmark items, however none of the items or page numbers are hyperlinks. I don't think there is an ODS feature that lets you specify that PDF TOC entries should also be hyperlinks.
ods _all_ close;
ods pdf
file="%sysfunc(pathname(WORK))\sample-%sysfunc(monotonic()).pdf"
contents=yes %* specify TOC be generated, can also specify with CONTENTS/NOCONTENTS;
;
ods proclabel "SASHELP.CLASS listing"; * Bookmark level 1;
title "SASHELP.CLASS";
options nodate nonumber;
proc print noobs data=sashelp.class
contents='' %* option as empty-string removes bookmark level 2;
;
run;
ods proclabel "SASHELP gender counts";
title "Gender frequency";
proc sgplot data=sashelp.class
description="Simple bar chart" %* option sets bookmark level 2;
;
vbar sex ;
run;
ods pdf close;
I have a stored Process which returns an Excel as Download (with long loading time because of big data). This works correct, but after download it leaves a blank page. So i want to put some html text in the blank page, best would be a loading icon before, and a "finished" information after downloading the excel. But when i use a ods html after/Before the excel output, instead of downloading the excel it puts the excel as HTML-TextOutput as well, is there a way to do both outputs in one Process?
Code Sample:
/* something like:*/
ods html body=_webout;
data _null_;
file _webout;
put '<img src="loading.gif" />';
run;
ods html close;
/*here is the Exceloutput which i use at the moment without htmloutput*/
%let RV=%sysfunc(appsrv_header(Content-type, application/vnd.ms-excel));
%let RV=%sysfunc(appsrv_header(Content-disposition,%str(attachment; filename=myExcel.xls )));
ods tagsets.excelxp file=_webout options(embedded_titles='yes' embedded_footnotes='yes'
sheet_interval='none' sheet_name='Result') ;
PROC PRINT DATA=AUSDRUCK UNIFORM NOOBS LABEL;
OPTIONS DATE NUMBER;
TITLE1"myExcel ";
VAR var1 var2 var3 var4 var5;
RUN;
ods tagsets.excelxp close;
/*and then something like:*/
ods html body=_webout;
data _null_;
file _webout;
put 'Excel download finished successfull';
run;
ods html close;
This can be achieved using ODS, but I have a constraint that I am not supposed to use ODS as I'm using Listing. I need to generate RTF reports which has super and subscript text in them. Below is the sample code which I was referring which uses ODS.
ods rtf file='temp.rtf';
ods escapechar='^';
proc print data=sashelp.class;
title 'this value is superscripted ^{super 2} ';
title2 'this value is subscripted ^{sub 2} ';
run;
ods rtf close;
I want to print superscript or subscript text in Proc report title or footnotes.
Silly constraint calls for equally silly solution - who needs ODS escapechar when you can hard-code the rtf control sequences for subscripts and superscripts?
x 'cd c:\temp';
/*Produce initial rtf without superscripts / subscripts*/
ods rtf file='temp.rtf';
proc print data=sashelp.class;
title 'this value is superscripted 2';
title2 'this value is subscripted 2';
run;
ods rtf close;
/*Add them in manually as per .rtf file format specification*/
data _null_;
infile "c:\temp\temp.rtf" lrecl = 32767;
file "c:\temp\want.rtf";
input;
length rtf $32767;
rtf = _infile_;
rtf = tranwrd(rtf, 'this value is superscripted 2', 'this value is superscripted \super 2 \nosupersub');
rtf = tranwrd(rtf, 'this value is subscripted 2', 'this value is subscripted \sub 2 \nosupersub');
put rtf;
run;
I don't believe this is possible in ODS LISTING. (Anyone who tells you you aren't using ODS is wrong, because listing is an ODS output destination just like all of the other destinations, but i'm assuming you mean you can't use anything other than ODS Listing, or use some of the common ODS tricks like ODS ESCAPECHAR).
However, ODS Listing doesn't have much available to it in terms of playing with fonts. You can put a super-2:
ods listing;
proc print data=sashelp.class;
title "Fun²";
run;
ods listing close;
by literally typing the character into your text, but that's not available for every possible superscript, and I don't think there are subscript equivalents in the listing font.
You can find a listing of characters online, for example in this paper. You can insert them with '##'x where ## is the 2 digit hex code for the character, or by typing them (alt+0178 for ² for example, or use character map to find them; make sure you use the right font.)
I'm trying to suppress HTML output and get PROC PRINT to output only to CSV, but ODS HTML Close doesn't seem to work.
My code is:
ODS HTML close;
ODS CSV file="\\..output folder..\filename.csv";
proc print data=test;
run;
ODS CSV close;
ODS HTML;
Your approach seems a bit odd, why resort to ods csv?
SAS has a proc export procedure:
proc export data=test outfile="\\..output folder..\filename.csv" dbms=CSV replace;
run;
You can further configure it to have a different delimiter, no headers etc.: http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000393174.htm
EDIT
In reply to your comment: i see two ways around the issues that keep you from trying proc export.
The first approach is setting the validvarname to ANY, which gives you great liberty in choosing variable names. E.g.:
options validvarname=ANY;
data test;
'Column Header Text I Want'n=1; output;
'Column Header Text I Want'n=5; output;
run;
proc export data=test outfile="\\..output folder..\filename.csv" dbms=CSV replace;
run;
Personally, i'm not a fan of the above approach, since i find that it leads to harder-to-read code when you no longer have some naming rules for variables.
A second approach - which i prefer - is to label the variable with the text you want it to have and put the label option on your proc export. E.g.:
data test;
label variable_name='Column Header Text I want';
variable_name=1; output;
variable_name=5; output;
run;
proc export data=test outfile="\\..output folder..\filename.csv" dbms=CSV replace LABEL;
run;
Note that there is a small distinction in the output: the first approach will not put quotes around your column names while the second approach will do that.
Finally, while doing some extra reading myself, i stumbled across this, which may be of help to you as well: http://www.sascommunity.org/wiki/Create_a_CSV_file_without_column_names/headers_in_row_1#DATA_NULL_with_a_PUT_statement.2C_all_fields_quoted
I'm been trying all day and finally got it for me. What I wanted suppress from the results viewer is just below here (and the end of a macro). The results I wanted in the results viewer and now called in a separate macro at the end...
Brubumski
ODS HTML close; * bsk;
ods results off; * bsk;
ods csvall file="&file1";
proc print data=tr_outds noobs; run;
ods csvall close; * bsk;
ods results on; * bsk;
ODS HTML; * bsk;
%OdsOn1(outds,outds2,tr_outds, file1, file2); * bsk;
%mend process_input_data_10_10;
%macro OdsOn1(outds,outds2,tr_outds, file1, file2);
proc freq data=outds;tables Group_nm/missing;run;
proc freq data=outds2;tables case_id/missing;run;
proc print data=tr_outds(obs=10) noobs; run;* bsk;
ods csvall file="&file2";
proc print data=cases noobs; run;
ods csvall close;
%mend OdsOn1;
Ah, I've found out the problem. The results window will still display HTML output which will really slow the program down as ODS HTML CLOSE seems to only affect ouput to a specific file, not the results window.
In order to stop that, I should have used ODS RESULTS OFF; instead.
ODS RESULTS OFF;
ODS CSV file="\\..output folder..\filename.csv";
proc print data=test;
run;
ODS CSV close;
EDIT: It seems that ODS RESULTS cannot be turned on and off at will to cause only certain PROC PRINT statements to generate outputs. This is really annoying for me, so I'm going with Shorack's PROC EXPORT methods.