Solved
Contributor
Posts: 71

# Counting observations

Hello

data count;
input Age Salary;
datalines;
30 20000
31 20600
32 35000
35 50000
36 50000
31 36500
40 50000
30 80000
36 50000
;
run;

I would like to get output as below
FRQ
30-35   6
36-40   3

Accepted Solutions
Solution
‎04-26-2016 12:50 AM
Super User
Posts: 23,724

## Re: Counting observations

1. Create a new variable that has your ranges, then run proc freq/tabulate. This you can try on your own.

2. Use a format and run proc freq/tabulate. This is illustrated below.

``````proc format;
value age_fmt
30 - 35 = '30 to 35'
36 - 40 = '36 to 40';
run;

proc freq data=count;
format age age_fmt.;
table age/out=want;
run;

*output table want is also created if you want a data set;``````

All Replies
Solution
‎04-26-2016 12:50 AM
Super User
Posts: 23,724

## Re: Counting observations

1. Create a new variable that has your ranges, then run proc freq/tabulate. This you can try on your own.

2. Use a format and run proc freq/tabulate. This is illustrated below.

``````proc format;
value age_fmt
30 - 35 = '30 to 35'
36 - 40 = '36 to 40';
run;

proc freq data=count;
format age age_fmt.;
table age/out=want;
run;

*output table want is also created if you want a data set;``````
🔒 This topic is solved and locked.