Grouping variable

E

Emjaysea

I need to create a new variable that groups ranges of another variable - as
for any value of var1 in (15,16,17,18,19) var2 would equal '15-19'. Var1 has
values ranging from 15-54 and I need them grouped into eight groups. I can't
figure out how to do this. Thanks.
 
J

John W. Vinson

On Fri, 14 Nov 2008 12:20:01 -0800, Emjaysea <Creating variable for ranges of
I need to create a new variable that groups ranges of another variable - as
for any value of var1 in (15,16,17,18,19) var2 would equal '15-19'. Var1 has
values ranging from 15-54 and I need them grouped into eight groups. I can't
figure out how to do this. Thanks.

I'd suggest creating a little table named Groupings (don't use the reserved
word Group). It should have three fields: Low, High and Groupname, and values
sucy as

15;19; "15-19"
20;26; "20-26"

and so on.

Join this table to your current table with a "Non Equi Join" - you'll need to
go into the SQL window to create this, you can't do it in the grid. Start in
the grid, though, joining var2 to Low; then go into SQL view and edit

INNER JOIN Groupings ON yourtable.var2 = Groupings.Low

to

INNER JOIN Groupings ON yourtable.var2 >= Groupings.Low AND yourtable.var2 <=
Groupings.High

Then use Groupname as your sorting and grouping argument in the Report, or
Group By in a Totals query.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top