Help using Base SAS procedures

label in PROC FREQ

Reply
Occasional Contributor
Posts: 8

label in PROC FREQ

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
Frequent Contributor
Posts: 95

Re: label in PROC FREQ

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]
SAS Super FREQ
Posts: 8,743

Re: label in PROC 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
Occasional Contributor
Posts: 8

Re: label in PROC FREQ

Thank you a lot; the recommended solution has solved the problem

Regards
Karl
Ask a Question
Discussion stats
  • 3 replies
  • 2895 views
  • 0 likes
  • 3 in conversation