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;
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.
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.
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?
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.
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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.