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 = 😎 tip=(tips);
by district;
run;
ods html5 close;
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>";
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:
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>";
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.