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

Hi

 

When I send a html graph to Microsoft word.

There always a table contains data from graph appears after the graph in word.

How can I prevent the table from appearing?

 

Thanks.

 

Here is the code I used for html graph:

data

 

 

 

test1;

 

 

infile datalines delimiter=',';

 

 

input target age percentage ;

 

 

datalines;

1,1,0.517

0,1,0.483

0,2,0.445

1,2,0.555

1,3,0.577

0,3,0.423

0,4,0.406

1,4,0.594

0,5,0.387

1,5,0.613

0,6,0.372

1,6,0.628

1,7,0.626

0,7,0.374

1,8,0.698

0,8,0.302

1,9,0.629

0,9,0.371

1,10,0.589

0,10,0.411

1,11,0.667

0,11,0.333

1,12,0.5

0,12,0.5

1,13,0.444

0,13,0.556

1,14,1

0,15,0.6

1,15,0.4

1,16,1

1,17,1

0,19,1

;

 

 

run;

 

ODS

 

 

NOPROCTITLE; TITLE;

TITLE1

 

 

"Target distribution by age";

FOOTNOTE

 

 

;

;

PROC

 

 

 

GCHART DATA=WORK.test1

;

 

 

VBAR

age

 

/

 

 

SUMVAR=percentage

 

 

SUBGROUP=target

DISCRETE

 

 

TYPE=SUM

;

RUN

 

 

 

; QUIT;

TITLE

 

 

; FOOTNOTE;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

One hint: use the the icons above to open a box that accepts code better, the SAS run box will accept code directrly from the SAS editor without adding a bunch of spaces.

 

Since you said you are sending this to Word, try using ODS RTF or ODS tagsets.RTF to create file that is RTF and much better for Word than any flavor of HTML

data work.test1;
infile datalines delimiter=','; 
input target age percentage ;
datalines;
1,1,0.517
0,1,0.483
0,2,0.445
1,2,0.555
1,3,0.577
0,3,0.423
0,4,0.406
1,4,0.594
0,5,0.387
1,5,0.613
0,6,0.372
1,6,0.628
1,7,0.626
0,7,0.374
1,8,0.698
0,8,0.302
1,9,0.629
0,9,0.371
1,10,0.589
0,10,0.411
1,11,0.667
0,11,0.333
1,12,0.5
0,12,0.5
1,13,0.444
0,13,0.556
1,14,1
0,15,0.6
1,15,0.4
1,16,1
1,17,1
0,19,1
;
run;
 
ods rtf file="D:\data\test.RTF";  /* <= Change this to a path on your system*/
ODS NOPROCTITLE; TITLE;
TITLE1 "Target distribution by age";
FOOTNOTE;
;
PROC GCHART DATA=WORK.test1;
   VBAR age /SUMVAR=percentage 
   SUBGROUP=target
   DISCRETE
   TYPE=SUM
   ;
   RUN; 
QUIT;
TITLE; FOOTNOTE;
ods RTF close;

 

A possibly not so  minor style note: If you are going to refer to a data set with a two level name such as Work.Test1 then make sure you create it as such: Data Work.Test1. There are environment when using USER libraries that your code as presented won't run.

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

I just ran your program and saved the result as HTML.

The graph is created dynamically from the data with a script in the HTML code.

After that, there follows the table with the data.

Quick and dirty fix would be to save the result as HTML, and use a text editor to remove the DIV that contains the table and all references to it.

 

Another, more elegant fix depends on your SAS architecture. Use ODS to create a HTML file, so only the graph is written to it. But this may also require moving the HTML from your SAS server to your local desktop.

R_E
Fluorite | Level 6 R_E
Fluorite | Level 6

Thanks KurtBremser

I did not try text editor since I did not use it before.

I created a word file using ods rtf recommended by Ballardw below. It works though I have to move the file from SAS server to my local dirve like you said.

ballardw
Super User

One hint: use the the icons above to open a box that accepts code better, the SAS run box will accept code directrly from the SAS editor without adding a bunch of spaces.

 

Since you said you are sending this to Word, try using ODS RTF or ODS tagsets.RTF to create file that is RTF and much better for Word than any flavor of HTML

data work.test1;
infile datalines delimiter=','; 
input target age percentage ;
datalines;
1,1,0.517
0,1,0.483
0,2,0.445
1,2,0.555
1,3,0.577
0,3,0.423
0,4,0.406
1,4,0.594
0,5,0.387
1,5,0.613
0,6,0.372
1,6,0.628
1,7,0.626
0,7,0.374
1,8,0.698
0,8,0.302
1,9,0.629
0,9,0.371
1,10,0.589
0,10,0.411
1,11,0.667
0,11,0.333
1,12,0.5
0,12,0.5
1,13,0.444
0,13,0.556
1,14,1
0,15,0.6
1,15,0.4
1,16,1
1,17,1
0,19,1
;
run;
 
ods rtf file="D:\data\test.RTF";  /* <= Change this to a path on your system*/
ODS NOPROCTITLE; TITLE;
TITLE1 "Target distribution by age";
FOOTNOTE;
;
PROC GCHART DATA=WORK.test1;
   VBAR age /SUMVAR=percentage 
   SUBGROUP=target
   DISCRETE
   TYPE=SUM
   ;
   RUN; 
QUIT;
TITLE; FOOTNOTE;
ods RTF close;

 

A possibly not so  minor style note: If you are going to refer to a data set with a two level name such as Work.Test1 then make sure you create it as such: Data Work.Test1. There are environment when using USER libraries that your code as presented won't run.

R_E
Fluorite | Level 6 R_E
Fluorite | Level 6

Thank you very much Ballardw!

 

Ods Rtf works for me. Though like KurtBremser mentioned above, I have to saved the word file on SAS server, then use Filzella move it my local desktop because of my department SAS architecture.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1682 views
  • 2 likes
  • 3 in conversation