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

Why this code don't generate the expected graphic (empty image)

 

proc sgplot data=sashelp.class tmplout="&demo./test.sas";
    vbar sex; 
run;

%include "&demo./test.sas";

proc sgrender data=sashelp.class template=sgplot;
run;

and generate the following warnings?

 

 WARNING: The BarChartParm statement named 'VBAR' will not be 
          drawn because one or more of the required arguments 
          were not supplied.
 WARNING: The BarChartParm statement named 'VBAR' will not be 
          drawn because one or more of the required arguments 
          were not supplied.
 WARNING: The BarChartParm statement named 'VBAR' will not be 
          drawn because one or more of the required arguments 
          were not supplied.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
xxformat_com
Barite | Level 11

I first didn't understood your answer and then I got it. The code needs to look as follow.

 

proc sgplot data=sashelp.class tmplout="&demo./test.sas";
    vbar sex; 
run;

%include "&demo./test.sas";


proc sql;
   create table class as
   select sex, count(*) as _FREQUENCY_
   from sashelp.class
   group by sex;
quit;


proc sgrender data=class template=sgplot;
run;

View solution in original post

4 REPLIES 4
Reeza
Super User

I think it's because the template has DYNAMIC statements. Those are based on your data and the proc is passing them initially but when you use SGRENDER you need to specify those parameters explicitly.

 

My guess as to what's going on anyways. 

 

https://documentation.sas.com/?docsetId=odsproc&docsetTarget=p1kt28i6uur3min15jrps9ttl228c.htm&docse...


@xxformat_com wrote:

Why this code don't generate the expected graphic (empty image)

 

proc sgplot data=sashelp.class tmplout="&demo./test.sas";
    vbar sex; 
run;

%include "&demo./test.sas";

proc sgrender data=sashelp.class template=sgplot;
run;

and generate the following warnings?

 

 WARNING: The BarChartParm statement named 'VBAR' will not be 
          drawn because one or more of the required arguments 
          were not supplied.
 WARNING: The BarChartParm statement named 'VBAR' will not be 
          drawn because one or more of the required arguments 
          were not supplied.
 WARNING: The BarChartParm statement named 'VBAR' will not be 
          drawn because one or more of the required arguments 
          were not supplied.

Thanks


 

 

Reeza
Super User

Actually taking another look at the code, it's using _freq_ which isn't calculated. So for the graph, SAS is first calculating the data and then displaying it. That calculation step does not happen with SGRENDER so you need to precalculate your numbers to display them.

 

EDIT: this does work as expected and is the answer to why it doesn't work. 

 

So, when you use VBAR SAS first processes the data to get the summaries as requested and then graphs the data. The Templateout only provides the code for graphing the data from the summaries, not the code to generate the summaries. You need to do that step yourself.

 

Here's a fully worked example:

 


proc sgplot data=sashelp.class tmplout="&path./Demo1.sas" ;
    vbar sex; 
run;



%include "&path./Demo1.sas";

*get your summaries;
proc freq data=sashelp.class;
table sex / out=summary (rename=count=_frequency_);
run;

*graph data;
proc sgrender data=summary template=sgplot;
run;
xxformat_com
Barite | Level 11

I first didn't understood your answer and then I got it. The code needs to look as follow.

 

proc sgplot data=sashelp.class tmplout="&demo./test.sas";
    vbar sex; 
run;

%include "&demo./test.sas";


proc sql;
   create table class as
   select sex, count(*) as _FREQUENCY_
   from sashelp.class
   group by sex;
quit;


proc sgrender data=class template=sgplot;
run;
xxformat_com
Barite | Level 11
Thank you. That's what I needed: adding a _frequency_ variable!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1369 views
  • 1 like
  • 2 in conversation