>>>>
>>>>Larry- I think what you are trying to do can be accomplished with one
>statement:
>>>>
>>>>SELECT count(*), distinct *;
>>>>FROM masterfile;
>>>>INTO CURSOR countfile;
>>>>WHERE inactive <> "Y";
>>>>GROUP BY agegrp, district
>>>>
>>>>This doesn't directly apply to your question, but could possibly reduce
>the time it takes to create your countfile table.
>>>>HTH
>>>
>Yes, I left out a few words...
>
>What if I want to group agegrp's into categories (Under_50 and Over_50) and
>get totals by category (assume that agegrp contains the actual age in
>years)????
Then you should just run another select on the resulting cursor from the
first select, like this
SELECT count(*) as cnt, *;
FROM masterfile;
INTO CURSOR countfile;
WHERE inactive <> "Y";
GROUP BY agegrp, district;
into cursor first
select agegrp>50 as over_50, sum(cnt) as cnt, district;
from first;
group by district, over_50;
into curs second
This way you'll have .t. or .f. in the over_50 column, and sum of
appropriate counts, without the need to run the whole select on the big
table again. Another approach could be
select district, sum(iif(agegrp>50,cnt, 0) as over_50,
sum(iif(agegrp<=50,cnt, 0) as under_50, ;
from first;
group by district;
into curs second
....which would give you one record per district, in a form more suitable
for reporting.