BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dave25
Quartz | Level 8

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

4 REPLIES 4
Reeza
Super User

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>"
Dave25
Quartz | Level 8
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?)
Reeza
Super User

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>";

Dave25
Quartz | Level 8
yep - amateur mistake - now works as I hoped - double thanks!!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1563 views
  • 2 likes
  • 2 in conversation