Data visualization with SAS programming

ods html5 Table of Contents - formatted values for by group

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

ods html5 Table of Contents - formatted values for by group

Related to the question I asked (and got a great answer to!) a couple weeks ago - I am now trying to create a table of contents with html5, with fomatted values for the by group.

 

From an example on the SAS site and a small macro, I'm able to get pretty close to what I want - but, two problems:

1) while the links appear in the table of contents, they don't take me to the graph;

2) I would like to get the formatted values, instead of 1, 2, etc. - tried what I have in my (limited) bag of tricks (for example, call symput, but can only get that to work in a datastep, and my macro is inside a proc step), with no luck.

- any suggestions would be appreciated!

 

 *not used in my code, but would like it;

proc format; value dfmt
1 = "South"
2 = "North";

run;

 

 

%macro mult;
%do i = 1 %to 2;
p "<h2><a href=#myreport&i'>&i</a><h2>";
%end;
%mend;


data test;
input District PCT_PROF PCT_FR_LUNCH;
Tips = 'PCT PROF: '|| strip(put(PCT_PROF, percent10.))|| ' / PCT FR Lunch: '|| strip(put( PCT_FR_LUNCH, percent10.));
cards;
1 .5 .4
1 .7 .5
1 .9 .6
2 .2 .4
2 .2 .5
2 .2 .6
;
run;

 

ods graphics / reset;
ods html5 path="." (url=none) file="test1.html" options(bitmap_mode="inline")
anchor="myreport";
proc odstext contents='';
p "<h1>---</h1>";
%mult;
run;
ods graphics / imagemap=on height=7in width=9in imagefmt=png;

Title "PCT Prof X FR Lunch";
proc sgplot data=test;
Scatter y = PCT_PROF x = PCT_FR_LUNCH /markerattrs=(symbol=circlefilled color=blue size = 8) tip=(tips);
by district;
run;
ods html5 close;


Accepted Solutions
Solution
‎03-19-2017 10:26 PM
Grand Advisor
Posts: 16,334

Re: ods html5 Table of Contents - formatted values for by group

Are you missing a quote right after the href=? Not sure how to get the macro variable to resolve in there as well...

 

Should be:

 

p "<h2><a href='#myreport&i'>&i</a><h2>";

View solution in original post


All Replies
Grand Advisor
Posts: 16,334

Re: ods html5 Table of Contents - formatted values for by group

[ Edited ]

Use %SYSFUNC and PUTN/PUTC instead. 

 

proc format ;
    value dfmt 1="South" 2="North";
run;

%macro mult;
    %do i=1 %to 2;
        %put p "<h2><a href=#myreport&i'>%sysfunc(putn(&i, dfmt))</a><h2>";
    %end;
%mend;

%mult;

Results:

 

p "<h2><a href=#myreport1'>South</a><h2>"
p "<h2><a href=#myreport2'>North</a><h2>"
Contributor
Posts: 25

Re: ods html5 Table of Contents - formatted values for by group

thanks! - that works perfect for my 2nd question - any ideas on question 1 - the links and the table of contents? (and how do "Accept" as 1/2 the solution?)
Solution
‎03-19-2017 10:26 PM
Grand Advisor
Posts: 16,334

Re: ods html5 Table of Contents - formatted values for by group

Are you missing a quote right after the href=? Not sure how to get the macro variable to resolve in there as well...

 

Should be:

 

p "<h2><a href='#myreport&i'>&i</a><h2>";

Contributor
Posts: 25

Re: ods html5 Table of Contents - formatted values for by group

yep - amateur mistake - now works as I hoped - double thanks!!
Post a Question
Discussion Stats
  • 4 replies
  • 108 views
  • 2 likes
  • 2 in conversation