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

I am having trouble changing the variable names for in my proc surveyfreq step. I also cannot change the name of the title. It keeps stating "distribution of x variable" etc. I have tried to use the RENAME , LABEL, and TITLE options to no avail. I am using SAS University. Here is my code:

 

*WITH RENAME OPTION;

title 'Percent of Americans Aged 20 and Older Who Adhered to Cholesterol Screening Guidelines by Insurance
and Routine Care Provider, 2011-2012';
proc surveyfreq data=nh.final5 (rename=(ins='Insurance'))(rename=(care='Routine Care'))
(rename=(cho5years='Cholesterol Screening within Past 5 Years'));
STRATA SDMVSTRA;
CLUSTER SDMVPSU;
WEIGHT WTINT2YR;
tables care*cho5years*ins/ plots=freqplot (type=dot scale=percent groupby=row);
by agecat2;
run;
 
 
*WITH LABEL OPTION;
title 'Percent of Americans Aged 20 and Older Who Adhered to Cholesterol Screening Guidelines by Insurance
and Routine Care Provider, 2011-2012';
proc surveyfreq data=nh.final5;
STRATA SDMVSTRA;
CLUSTER SDMVPSU;
WEIGHT WTINT2YR;
tables care*cho5years*ins/ plots=freqplot (type=dot scale=percent groupby=row);
by agecat2;
label ins='Insurance'
care='Routine Care'
cho5years='Cholesterol Screening within Past 5 Years';
run;
 
Screen Shot 2020-11-20 at 14.52.43.png
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

With Proc Surveyfreq, or other of the survey procedures, you use ODS OUTPUT. You need to determine the name of the object the procedure generates and then add statements like:

 

ods output <objectname> = <desired dataset name>.

You can get the object names by either checking the DETAILS section of the procedure documentation under the ODS Tables or Ods Graphics, which will have the options needed to create them as well.

Or you can run your code once with ODS Trace on; before and ODS trace off; after (to stop the trace). The log will have all of the objects created. So you could add the statement(s) and rerun the code to create the output data sets.

 

An example using proc freq:

180  ods trace on;
181  proc freq data=sashelp.class;
182  tables sex*age;
183  run;


Output Added:
-------------
Name:       CrossTabFreqs
Label:      Cross-Tabular Freq Table
Template:   Base.Freq.CrossTabFreqs
Path:       Freq.Table1.CrossTabFreqs
-------------

The "Output Added" is where the trace information starts. The NAME: is the name of the object you want in the ods output statement.

 

You can use the plot objects created to get plot data if there are features of the plot you wouldn't have in your raw data such as confidence limits. Sometimes you may need to modify the data. Look very closely at the output data set as the contents will have stuff you want and the names may not quite be what you expect.

 

With graphs created with a BY statement in the analysis you may want to investigate Proc SGPANEL to plot the data and use the Panelby statement with the same by variable for controlling some of the plots.

 

Another option is that you can manually edit graphs which requires some system options, opening graph and manually making changes. This gets pretty clunky as you are limited to specific ODS destinations and getting the ODS resulting file into other documents has other manual steps involved. Search the documentation for "Statistic Graphics Using ODS" for a starting point.

View solution in original post

4 REPLIES 4
ballardw
Super User

Many of the analysis procedures that produce plots that are intended as analysis aids and not "camera ready" for publication.

If you want control over appearance then the approach is to create an output data set with the information you need and use that in a another graphing procedure.

 

I bet that the TABLES produced have the title appear before them.

admendez03
Fluorite | Level 6

That make sense. So, make a data set that has all the values that I need from the proc surveyfreq and then do, let's say, a proc boxplot (or something of that nature) in order to have full control of what is displayed on the graph? If that is what you mean, how do I go about doing that in terms of creating a data set from the proc surveyfreq values?

ballardw
Super User

With Proc Surveyfreq, or other of the survey procedures, you use ODS OUTPUT. You need to determine the name of the object the procedure generates and then add statements like:

 

ods output <objectname> = <desired dataset name>.

You can get the object names by either checking the DETAILS section of the procedure documentation under the ODS Tables or Ods Graphics, which will have the options needed to create them as well.

Or you can run your code once with ODS Trace on; before and ODS trace off; after (to stop the trace). The log will have all of the objects created. So you could add the statement(s) and rerun the code to create the output data sets.

 

An example using proc freq:

180  ods trace on;
181  proc freq data=sashelp.class;
182  tables sex*age;
183  run;


Output Added:
-------------
Name:       CrossTabFreqs
Label:      Cross-Tabular Freq Table
Template:   Base.Freq.CrossTabFreqs
Path:       Freq.Table1.CrossTabFreqs
-------------

The "Output Added" is where the trace information starts. The NAME: is the name of the object you want in the ods output statement.

 

You can use the plot objects created to get plot data if there are features of the plot you wouldn't have in your raw data such as confidence limits. Sometimes you may need to modify the data. Look very closely at the output data set as the contents will have stuff you want and the names may not quite be what you expect.

 

With graphs created with a BY statement in the analysis you may want to investigate Proc SGPANEL to plot the data and use the Panelby statement with the same by variable for controlling some of the plots.

 

Another option is that you can manually edit graphs which requires some system options, opening graph and manually making changes. This gets pretty clunky as you are limited to specific ODS destinations and getting the ODS resulting file into other documents has other manual steps involved. Search the documentation for "Statistic Graphics Using ODS" for a starting point.

Watts
SAS Employee

To display variable labels instead of variable names in the tables and plots that PROC SURVEYFREQ produces, you can specify the VARHEADER=LABEL option in the PROC SURVEYFREQ statement. 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1126 views
  • 3 likes
  • 3 in conversation