BookmarkSubscribeRSS Feed
Karolus
Obsidian | Level 7
Hi, I have a problem defining a label.

The dataset contains a variable called 'Month' formatted as numbers;
when I use the following code:

proc freq data=mylib.history;
table month;
title 'PRoc freq without format';
run;


I get the following output:

PRoc freq without format 227

The FREQ Procedure

Season

Cumulative Cumulative
MONTH Frequency Percent Frequency Percent
__________________________________________________
1 10 8.33 10 8.33
2 10 8.33 20 16.67
3 10 8.33 30 25.00
4 10 8.33 40 33.33
5 10 8.33 50 41.67



However, I'd like to change the name of the column 'Month' by "Active Months". For that; I used the command label:

proc freq data=mylib.history;
table month;
title 'PRoc freq without format';
label month ='Active Months';
run;

However, the label 'month' is not changed, instead, my proposed new lable appears on top of the output, like a title:



Active Months

Cumulative Cumulative
MONTH Frequency Percent Frequency Percent
_______________________________________________
1 10 8.33 10 8.33
2 10 8.33 20 16.67
3 10 8.33 30 25.00


What I'm doing wrong? I also tried adding a label in the DATA procedure, but with the command PROC FREQ, still I got the name of the original variable and the label I want on top of the table, instead of replacing the name of 'month'.

Kind regards
Karolus
3 REPLIES 3
1162
Calcite | Level 5
I couldn't figure out how to change the column header within PROC FREQ, but I did come up with this solution. Write the results of your freq procedure to another SAS dataset and print that dataset. With the proper options, you can get the label headers you want. How would this work?
[pre]
proc freq;
table month / out=work.freq outcum;
run;

proc print data=work.freq noobs label;
run;
[/pre]
Cynthia_sas
SAS Super FREQ
Hi:
This Tech Support note explains what needs to happen:
http://support.sas.com/kb/23/350.html

The short explanation is that SAS procedures (like PROC FREQ and PROC MEANS and PROC UNIVARIATE) work in conjunction with a TABLE template in order to produce output (such as LISTING window output or ODS output).

In order to have the LABEL used with PROC FREQ, you have to change the TABLE template that works with PROC FREQ. The Tech Support note contains a code example. If you have problems with the code, then you might consider contacting Tech Support for more help.

cynthia
Karolus
Obsidian | Level 7
Thank you a lot; the recommended solution has solved the problem

Regards
Karl

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 35409 views
  • 2 likes
  • 3 in conversation