I'm creating a histogram as follows:
options papersize=(10in 10in);
goptions device=pdfc vsize=4in htext=10ptk;
Options topmargin="0in" bottommargin="0in" leftmargin="0in" rightmargin="0in";
ods pdf file="&folder/histo1.pdf";
goptions hsize=10in vsize=10in border;
ods select where=(_name_ ? 'Histogr');
proc univariate data=phd.customers;
var BetCount;
histogram BetCount / name='histogr';
run;
ods pdf close;
I want to have an output pdf similar to this one, with no margins and crop to the edge of the histogram: http://pgfplots.sourceforge.net/h_example_22.pdf
Thanks for any help at all on this.
Related
How to define the dimensions of an image to be added to a report created in SAS (ods rtf)?
I use the following procedure:
ods graphics on / width=4.5in height=3.5in;
data tt1;
image="&blabla\tt_general.jpg";
output;
run;
proc report data=tt1 noheader nofs style={frame=void rules=none protectspecialchars=off outputwidth=80%} nowindows;
column image;
define image / "" display WIDTH=10 style={cellwidth=18cm};
compute image;
call define( _col_, "Style", "Style=[PREimage='"!!image!!"']");
image="";
endcomp;
run;
Maybe there is a better way to include an image in a report, to define the width and height?
You can place a preimage= style reference in an ods text statement.
Example:
* create some arbitrary image to be shown in rtf;
%let workpath = %sysfunc(pathname(WORK));
ods listing gpath="&workpath";
ods graphics / reset imagename="carbars" outputfmt=jpg;
proc sgplot data=sashelp.cars;
vbar make / group=type;
run;
ods listing close;
ods rtf file="c:\temp\myoutput#%sysfunc(monotonic()).rtf";
ods escapechar = '^';
ods text = "^S={preimage=""&workpath.\carbars.jpg""}"; %* <---- place image in rtf;
ods rtf close;
How can I output distribution charts in a pdf format? I only need the chart from a proc univariate of all the variables in a table - not any additional metrics.
ods pdf file="aaaa.pdf
TITLE 'Summary of Weight Variable (in pounds)';
PROC UNIVARIATE DATA = sashelp.class NOPRINT;
HISTOGRAM _all_ / NORMAL;
RUN;
ods pdf close
You use ODS SELECT _chartname_ to limit the output to what you want. You need to remove the NOPRINT option though or no output is generated to display regardless of destination.
It looks like univariate produces: CDFPlot, Histogram, PPplot, Probplot, QQplot so assuming you want just the histogram add the following line to your code:
ods select histogram;
Full code:
ods pdf file="aaaa.pdf;
ods select histogram;
TITLE 'Summary of Weight Variable (in pounds)';
PROC UNIVARIATE DATA = sashelp.class ;
HISTOGRAM _all_ / NORMAL;
RUN;
ods pdf close
Add it before or within your PROC UNIVARIATE.
PS. You're missing a semicolon on your ODS PDF statements at the top and bottom.
A good blog post from the SAS website on this is available here.
I am trying to use hidden_rows in place of hidden_columns, but it doesn't work.
Any help will be appreciated.
ods tagsets.excelxp file="spacing.xls" style=statistical
options( hidden_columns='1,2,3');
proc print data=sashelp.class;
run;
ods tagsets.excelxp close;
tagsets.excelxp does not have an option hidden_rows. The tagset documentation can be written to the log window using this code:
ods tagsets.excelxp file="sandbox.xml" options (doc='all');
ods tagsets.excelxp close;
In what context are you trying to hide rows in the Proc REPORT output ? detail lines, group lines, summary lines ?
In SAS, when I use the following code, my rtf file shows everything like I want it to be. But in 'Results - Sas Report' every marker is a circle (although they are all different colors). How can I change this, so it looks exactly the same as in the rtf file?
%modstyle(parent= statistical, name= mystyle, type= CLM,
colors= red green blue purple,
markers= star plus circle square);
ods rtf file=".../scatterplot.rtf" style=mystyle;
proc sgplot data=datafile;
scatter y=y x=x /group=groups;
run;
ods rtf close;
Your problem is that you're not adding the style commands to the current HTML destination (which is what Results outputs to, assuming you're in 9.3+).
You can easily override this. Note the one extra line I added (the ods html line). I don't specify a location for the file - that way it just overrides the current option without changing the destination.
%modstyle(parent= statistical, name= mystyle, type= CLM,
colors= red green blue purple,
markers= star plus circle square);
ods rtf file="c:\temp\scatterplot.rtf" style=mystyle;
ods html style=mystyle;
proc sgplot data=sashelp.class;
scatter x=height y=weight /group=age;
run;
ods rtf close;
I'm running the following code to output a histogram of a certain variable:
ods results off;
ods listing close;
ods pdf file="&folder/temp.pdf";
title ;
* Histogram of betCount;
proc univariate data=want;
var BetCount;
histogram;
*label sex=' ' height='Height (cm)';
run;
ods pdf close;
ods listing;
ods results on;
It does create a PDF, but there's lots of extra tables and output. I just want to see the histogram only, as I'm read into latex as part of a \minipage with six figures in it. I have done this manually before by taking a screenshot of the required region, pasting into Paint and coverting to PDF or PNG: I don't want to go down that road again! How can this be done in general for graphs and plots in SAS?
Thanks for any help at all.
You can name the graph and then use ODS SELECT to select (only) it. (ODS TRACE ON will help you see it in the log.)
ods trace on;
ods pdf file="c:\temp\myfile.pdf";
ods select histogr;
proc univariate data=sashelp.class;
var age;
histogram age/name="Histogr" ;
run;
ods pdf close;