The beauty of using PROC FORMAT is that you do not need to create a new variable that contains the bin information; you simply apply the format to an existing variable. Examples and a discussion are given in "5 reasons to use PROC FORMAT to recode variables in SAS."
I think the following example might suit your needs:
data Have;
input Months @@;
RawMonts = Months;
datalines;
0 11 12 13 23 24 25 35 36 37 59 60 61 73
11.9 12.1 13.3 23.7 24.2
;
/* create a YOL format */
proc format;
value YOLFmt
low - 12 = "0-12 Months" /* <= 12 */
12 <- 24 = "13-24 months" /* (12, 24] */
24 <- 36 = "25-36 months" /* (24, 36] */
36 <- 60 = "36-60 months"
60 <- high = "61+ months";
run;
/* apply the format */
proc print data=Have;
format Months YOLFmt.;
run;
/* apply the format in a computational procedure */
proc freq data=Have;
format Months YOLFmt.;
tables Months / nocol norow nopercent;
run;
Although it is rarely necessary, you can also use the format to create a NEW variable:
/* if necessary, you can create a new variable, but it is rarely necessary */
data Want;
set Have;
length YOL $12;
YOL = put(Months, YOLFmt.);
run;
proc print data=Want;
run;
... View more