Data visualization with SAS programming

SGPLOT Produces HTML in Color but RTF in B&W

Reply
Regular Contributor
Posts: 220

SGPLOT Produces HTML in Color but RTF in B&W

I must have some kind of option turned on that I am not seeing, but when I run the macro shown below, the output is produced in the HTML results viewer as well as in the stored .RTF file that I specify.  Attached are the two outputs (I couldn't attach the RTF, so the same is in PDF).  I want the HTML look in the RTF file.  Is there a reason why the HTML shows colored bars while the RTF shows B&W line patterns?

%macro waterfall(dsin=, whr=%str(), yvar=, byvar=, title=%str(), ylab=%str(), outpath=%str(), filename=%str(), barwidth=3);

      /* Display error message if WATERFALL dataset is attempting to be overwritten */

      %if %sysfunc(upcase(&dsin.))=WATERFALL %then %do;

            %put ERROR: The dataset WATERFALL is used in the waterfall macro.  Please rename your input dataset and rerun the macro;

            %return;

      %end;

      /* Get variable type and format of BYVAR */

      proc sql noprint;

            select type, format into :vartyp, :varfmt from sashelp.vcolumn

            where upcase(memname)=upcase("&dsin.") & upcase(name)=upcase("&byvar.");

      quit;

      /* Subset DSIN into WATERFALL & sort */

      data waterfall;

            set &dsin.;

            where &whr.;

      run;

      proc sort data=waterfall;

            by &byvar. descending &yvar.;

      run;

      data waterfall;

            set waterfall;

            n=_n_;

      run;

      /* Create waterfall plot */

      options formchar="|____|+|___+=|_/\<>*" pageno=1 nonumber nodate orientation=landscape center;

      ods listing close;

      ods pdf file="&outpath.\&filename..pdf" style=journal;

/*    goptions reset=all ftext=swissl ftitle=swissl hsize=9 in vsize=6.5 in;*/

      title1 "&title.";

      proc sgplot data=waterfall;

            where &yvar.^=.;

            needle x=n y=&yvar. / group=&byvar. lineattrs=(thickness=&barwidth.);

            refline 0;

            keylegend / across=1 position=topleft location=inside;

            xaxis display=none;

            yaxis grid values=(-100 to 150 by 50) label="&ylab.";

      run;

      quit;

      ods pdf close;

      ods listing;

      title; footnote;

/*    proc datasets lib=work;*/

/*          delete waterfall;*/

/*    run;*/

      quit;

%mend waterfall;

Attachment
Grand Advisor
Posts: 17,396

Re: SGPLOT Produces HTML in Color but RTF in B&W

Try changing the style or removing the style=journal option.

Regular Contributor
Posts: 220

Re: SGPLOT Produces HTML in Color but RTF in B&W

I have removed the style=journal option (it is just by habit that that is in there).  I got color output, but I have dashed lines for the red bars.  Should I specify a certain style that will not give dashed needles?

SAS Super FREQ
Posts: 1,081

Re: SGPLOT Produces HTML in Color but RTF in B&W

You have specified style=journal for the PDF destination, so you are getting what you ask for Smiley Happy.  Remove that and reset it back to one of the color styles.

 

ods pdf file="&outpath.\&filename..pdf" style=journal;

Grand Advisor
Posts: 10,223

Re: SGPLOT Produces HTML in Color but RTF in B&W

Suggestion: Use the same style for HTM and PDF if you are generating both. Different styles are likely to have different color, font and other appearnce differences.

Regular Contributor
Posts: 220

Re: SGPLOT Produces HTML in Color but RTF in B&W

I have removed the style=journal option (it is just by habit that that is in there).  I got color output, but I have dashed lines for the red bars.  Should I specify a certain style that will not give dashed needles?

SAS Super FREQ
Posts: 1,081

Re: SGPLOT Produces HTML in Color but RTF in B&W

Set lineattrs=(pattern=solid) on the needle plot.

Yes, with SAS 9.3, the HTMLBlue style will delay usage of line patterns till after all colors are used up.

Regular Contributor
Posts: 220

Re: SGPLOT Produces HTML in Color but RTF in B&W

I didn't mark this as a question, so I couldn't give you points as a correct answer.  Both of these options did the trick.  Thank you for your sharp eye!  Such simple fixes that I spent so much time searching for.

Ask a Question
Discussion stats
  • 7 replies
  • 515 views
  • 0 likes
  • 4 in conversation