BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Nasser_DRMCP
Lapis Lazuli | Level 10

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

8 REPLIES 8
ballardw
Super User

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.

 

 

WarrenKuhfeld
Rhodochrosite | Level 12

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.

Nasser_DRMCP
Lapis Lazuli | Level 10

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

 

WarrenKuhfeld
Rhodochrosite | Level 12

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.

ballardw
Super User

Try this change:

 

proc sql noprint ;

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

quit

Reeza
Super User

@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. 

 

 

Nasser_DRMCP
Lapis Lazuli | Level 10
Thanks a lot Ballardw
Cynthia_sas
SAS Super FREQ

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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