@SChander1 wrote:
Hello everyone,
how can I combine multiple age people into two groups?? Lower than 65 and above 65?
Thanks
90% or time or more when I need such, grouping on a single value, I use a custom format. Reasons: I can change or use a different format and do not need to change the data set at all, the code for ensuring non-overlapping ranges in the format code is usually much simpler.
Example:
/* create a data set with some age groups*/
data example;
do age = 1 to 85;
do j= 1 to rand('integer',2,6);
output;
end;
end;
run;
proc format library = work;
value age65_
1 - 65 = '65<'
65<-high = '65+'
;
value age10yr
1 -10= ' 1-10'
11-20= '11-20'
21-30= '21-30'
31-40= '31-40'
41-50= '41-50'
51-60= '51-60'
61-70= '61-70'
71-80= '71-80'
81-high='81+'
;
proc freq data=example;
tables age;
format age age65_.;
run;
proc freq data=example;
tables age;
format age age10yr.;
run;
The first data set is to build a data set with a number of age values. Then two formats to group age. I actually have more than a dozen of such with other values such as "out of range" because my users have different boundary ages for their processes.
Note that a format definition name cannot end in a numeral because formats usage allows specifying the number of display characters at run time such as:
proc freq data=example;
tables age;
format age age10yr2.;
run;
which shows the lower bound of the age group only.
Almost all of the analysis, graphing and reporting procedures will support groups created by a format.
... View more