Desktop productivity for business analysts and programmers

How to stop table contains data from graph appearing after sending the html graph to word

Accepted Solution Solved
Reply
Occasional Contributor R_E
Occasional Contributor
Posts: 8
Accepted Solution

How to stop table contains data from graph appearing after sending the html graph to word

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;

 

 


Accepted Solutions
Solution
‎01-20-2016 03:51 PM
Grand Advisor
Posts: 10,210

Re: How to stop table contains data from graph appearing after sending the html graph to word

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


All Replies
Esteemed Advisor
Posts: 6,646

Re: How to stop table contains data from graph appearing after sending the html graph to word

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor R_E
Occasional Contributor
Posts: 8

Re: How to stop table contains data from graph appearing after sending the html graph to word

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.

Solution
‎01-20-2016 03:51 PM
Grand Advisor
Posts: 10,210

Re: How to stop table contains data from graph appearing after sending the html graph to word

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.

Occasional Contributor R_E
Occasional Contributor
Posts: 8

Re: How to stop table contains data from graph appearing after sending the html graph to word

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.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 323 views
  • 2 likes
  • 3 in conversation