Hello,
I created formats and labels for my variables, but when I create tables, the variable name (ex: newrace) is displaying in addition to the label I created. I want only the label to show (ex: Race) and I am not sure what I'm doing wrong?
[My formatted values appear the way I want them to and replace their values of 1 and 0 (ex: Yes No)]
Data library.dataset;
set dataset;
Label
sad="Sad for 2 or more weeks during the past 12 months"
newrace="Race"
;
run;
proc freq data=library.datasetorder=freq;
format newrace race. sad yesno.;
table newrace*sad;
run;
If you must use proc freq, and custom reporting is better done in either Proc Tabulate or Report, you would have to modify the ODS templates that the procedure uses and would likely mean more than one as one-way frequency and two-way frequency tables differ.
An example:
proc tabulate data=library.dataset; class newrace /order=freq; class sad; format newrace race. sad yesno.; table newrace all='Total', (sad all='Total') * (n='Count' pctn='table %') ; run;
Proc tabulate will display the label, if one is defined, by default and no variable name. You can modify the displayed label in use with the overide variable='some text' in a table statement as shown with the statistics. The ALL is to get a summary of the combined class variable. Note that the comma is used to separate dimensions. In the example the first dimension is only the newrace variable. If you also, for example, had an Age variable on the same line you would have a single table with race values above the age values. The * is used to nest variables and/or statistics and ( ) create a display group treated together. If you used something like newrace*age you would get each age as a row within a race category.
If you must use proc freq, and custom reporting is better done in either Proc Tabulate or Report, you would have to modify the ODS templates that the procedure uses and would likely mean more than one as one-way frequency and two-way frequency tables differ.
An example:
proc tabulate data=library.dataset; class newrace /order=freq; class sad; format newrace race. sad yesno.; table newrace all='Total', (sad all='Total') * (n='Count' pctn='table %') ; run;
Proc tabulate will display the label, if one is defined, by default and no variable name. You can modify the displayed label in use with the overide variable='some text' in a table statement as shown with the statistics. The ALL is to get a summary of the combined class variable. Note that the comma is used to separate dimensions. In the example the first dimension is only the newrace variable. If you also, for example, had an Age variable on the same line you would have a single table with race values above the age values. The * is used to nest variables and/or statistics and ( ) create a display group treated together. If you used something like newrace*age you would get each age as a row within a race category.
Thank you, this code worked for displaying the labels the way I hoped to!
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!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.