The SAS Output Delivery System and reporting techniques

proc sgplot create a chart but also an unexpected table

Accepted Solution Solved
Reply
Contributor
Posts: 35
Accepted Solution

proc sgplot create a chart but also an unexpected table

Hello,

I would like to create 3 charts in the a single doc rtf. each chart is based on a different dataset.

The names of dataset have suffix, as "Data_TYPE_1",  "Data_TYPE_2",  and "Data_3", 

So, I have created a loop with 3 iterative. (between ODS RTF and ODS RTF close) And the variable is set to 1, 2, 3.

I manage to create the chart but there is one page with an unexpected table that shows the varaible value.I would like to remove it !

Thanks in adance for your help

Nasser

 


Accepted Solutions
Solution
2 weeks ago
Super User
Posts: 10,550

Re: proc sgplot create a chart but also an unexpected table

Try this change:

 

proc sql noprint ;

select RAC_Label into :v_RAC_Label from RAC_Values where RAC_Indexe = &i ;

quit

View solution in original post


All Replies
Super User
Posts: 10,550

Re: proc sgplot create a chart but also an unexpected table

Show the code that you ran for the job. If there is a macro involved then post the code for the macro as well. Best is to paste it from the editor into a code box opened with the forum {i} menu icon at the top of the message window.

 

 

SAS Employee
Posts: 119

Re: proc sgplot create a chart but also an unexpected table

I'm going to guess you have something besides proc sgplot in your macro do loop?  If not, can you please supply code?  I have never come across proc sgplot creating a table.

Contributor
Posts: 35

Re: proc sgplot create a chart but also an unexpected table

[ Edited ]

thanks both for your quick reponse. below my code. note that the variable v_RAC_Label has the value, "CONSO", "HYPO", and "PP"

because I have 3 dataset BEH_SUITE_INDIC_CONSO, BEH_SUITE_INDIC_HYPO and BEH_SUITE_INDIC_PP.

my problem is that RAC_Label is displayed in the rtf as well

 

%macro Loop_Rac_ODS(count) ;
ODS RTF startpage = yes FILE = "&filename." style = Sapphire ;
%Do i=1 %To &count ;
proc sql ;
select RAC_Label into :v_RAC_Label from RAC_Values where RAC_Indexe = &i ;
quit ;
proc sgplot data = BEH_SUITE_INDIC_&v_RAC_Label ;
series x = ANNEE_AMO_SUITE y = ratio / group = &v_AXE. lineattrs=(pattern=solid) ;
xaxis display=(nolabel);
yaxis display=(nolabel);
run;
%End ;
ODS RTF CLOSE ;
%Mend Loop_Rac_ODS ;
 
%Loop_Rac_ODS(3) ;

 

SAS Employee
Posts: 119

Re: proc sgplot create a chart but also an unexpected table

specify:

ods trace on;

 

then run your program.  Look at the log and identify the name of the table.  If the name is name, then add

 

ods exclude name;

 

to the proc sql step.

Solution
2 weeks ago
Super User
Posts: 10,550

Re: proc sgplot create a chart but also an unexpected table

Try this change:

 

proc sql noprint ;

select RAC_Label into :v_RAC_Label from RAC_Values where RAC_Indexe = &i ;

quit

Super User
Posts: 17,959

Re: proc sgplot create a chart but also an unexpected table

@ballardwsolution is correct. Without the NOPRINT option, SQL with a select creates a table and that's what's appearing in your output. You didn't specify but it's probably the first thing generated.

 

It looks like the data set was split for some reason? If all the graphs are the same, you should be able to use BY processing unless you separated the datasets earlier on which now leads you to require macro loops everywhere instead of base code. In general, this isn't a good idea. 

 

PS. Please post your code using the insert code button. 

 

 

Contributor
Posts: 35

Re: proc sgplot create a chart but also an unexpected table

Thanks a lot Ballardw
SAS Super FREQ
Posts: 8,744

Re: proc sgplot create a chart but also an unexpected table

Hi:

  It is nearly impossible to make a constructive comment without seeing an example of your data and ALL your code.

 

  However, for debugging, if I remove the concept of macro processing and just have 1 ODS "sandwich" with 3 invocations of PROC SGPLOT, using SASHELP.HEART, I do not see any stray tables in the output.

 

  So it is either the code that your macro is generating (which you can reveal with the MPRINT option) or some other code that is inside your ODS RTF invocation.

 

  Here's the code that I ran to test 3 SGPLOTS in one ODS RTF file:

ods rtf file='c:\temp\test_sgplot.rtf' gtitle;

proc sgplot data=sashelp.heart;
  where chol_status = 'High';
  scatter x=height y=weight / group=sex;
  title '1) High Cholesterol';
run;
 
proc sgplot data=sashelp.heart;
  where chol_status='High';
  scatter x=height y=weight / group=smoking_status 
          markerattrs=(symbol=diamond);
  title '2) Smoking Status and High Cholesterol';
run;
 
proc sgplot data=sashelp.heart;
  where chol_status='High';
  scatter x=height y=weight / group=bp_status
          markerattrs=(symbol=triangle);
  title '3) Blood Pressure Status and High Cholesterol';
run;
ods rtf close;

 I don't see any extra tables. I used the GTITLE option so the SAS title would go into the graph image and not into the RTF file.

 

My suggestion would be to "unmacro" your code and try 3 separate SGPLOTS as I show here to make sure that your 3 SGPLOTS work correctly, and then "macro-ize" again to see whether something in the macro logic is inserting stray text or procedure output that you don't want.

 

cynthia

☑ This topic is solved.

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

Discussion stats
  • 8 replies
  • 325 views
  • 2 likes
  • 5 in conversation