BookmarkSubscribeRSS Feed
djbateman
Lapis Lazuli | Level 10

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;


SGPlot HTML Waterfall.png
7 REPLIES 7
Reeza
Super User

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

djbateman
Lapis Lazuli | Level 10

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?

Jay54
Meteorite | Level 14

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;

ballardw
Super User

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.

djbateman
Lapis Lazuli | Level 10

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?

Jay54
Meteorite | Level 14

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.

djbateman
Lapis Lazuli | Level 10

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1386 views
  • 0 likes
  • 4 in conversation