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.