I want to control the output of the proc freq using proc template and I want to change the title of the plot I output using the option. Here is the code:
proc format; picture pctfmt (round) other="009.9%"; run; proc template; define crosstabs Base.Freq.CrossTabFreqs; cellvalue frequency percent RowPercent ColPercent; define frequency; format=8.; header="Count"; end; define percent; format=pctfmt.; header="Overall %"; end; define RowPercent; header="Row Pct"; format=6.2; label="Percent of Row Frequency"; end; define ColPercent; header="Col Pct"; format=6.2; label="Percent of Column Frequency"; end; define header tableof; text "Table of " _row_label_ " by " _col_label_; end; define header rowsheader; text " "; end; define header colsheader; text " "; end; cols_header=colsheader; rows_header=rowsheader; header tableof; end; define statgraph Base.Freq.Graphics.ClusterPercentChart; /* more code here */ entrytitle "Distribution of" _row_label "by" _col_label; run; /*compare by sex*/ /*R5*/ proc freq data = subset; label y1p_G_GIRL = "Gender" R5status = "R5"; title "Table of Gender by R5 status"; table y1p_G_GIRL * R5status/nopercent chisq plots=freqplot(groupby=column twoway=cluster scale=percent); format R5status $normal.; format y1p_G_GIRL sex.; run;
I want to change the variable name into Gender here using proc template, it seems that it is doable using "define statgraph Base.Freq.Graphics.xxxxxxx;", but I do not what is the plot name should I use in proc template.
Looking for your reply.
You can get the template name by using
ODS TRACE ON;
(Documentation for ODS TRACE is here.)
I think the template for your plot is Base.Freq.Graphics.StackedPercentChart.
Although you can technically do this, using SGPLOT seems infinitely easier. Is that an option?
A few different examples are available here.
https://blogs.sas.com/content/graphicallyspeaking/2016/11/27/getting-started-sgplot-part-2-vbar/
@gx2144 wrote:
I want to control the output of the proc freq using proc template and I want to change the title of the plot I output using the option. Here is the code:
proc format; picture pctfmt (round) other="009.9%"; run; proc template; define crosstabs Base.Freq.CrossTabFreqs; cellvalue frequency percent RowPercent ColPercent; define frequency; format=8.; header="Count"; end; define percent; format=pctfmt.; header="Overall %"; end; define RowPercent; header="Row Pct"; format=6.2; label="Percent of Row Frequency"; end; define ColPercent; header="Col Pct"; format=6.2; label="Percent of Column Frequency"; end; define header tableof; text "Table of " _row_label_ " by " _col_label_; end; define header rowsheader; text " "; end; define header colsheader; text " "; end; cols_header=colsheader; rows_header=rowsheader; header tableof; end; define statgraph Base.Freq.Graphics.ClusterPercentChart; /* more code here */ entrytitle "Distribution of" _row_label "by" _col_label; run; /*compare by sex*/ /*R5*/ proc freq data = subset; label y1p_G_GIRL = "Gender" R5status = "R5"; title "Table of Gender by R5 status"; table y1p_G_GIRL * R5status/nopercent chisq plots=freqplot(groupby=column twoway=cluster scale=percent); format R5status $normal.; format y1p_G_GIRL sex.; run;
I want to change the variable name into Gender here using proc template, it seems that it is doable using "define statgraph Base.Freq.Graphics.xxxxxxx;", but I do not what is the plot name should I use in proc template.
Looking for your reply.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.