Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: Merging and counting variables

From   "Michael Blasnik" <>
To   <>
Subject   st: Re: Merging and counting variables
Date   Fri, 23 Sep 2005 13:33:49 -0400

It's not clear if you really want the merged dataset or just the count. If you want the merged dataset, what is it about the -merge- command you can't figure? If you just want the count, you could:

1) create a dataset with the counts by county/state:

use associations
bysort countystate: gen count=_N
by countystate: keep if _n==1
sort countystate
save associationcount

2) merge that dataset into the master dataset

use master
sort countystate
merge countystate using associationcount

Michael Blasnik

----- Original Message ----- From: "DE S" <>
To: <>
Sent: Friday, September 23, 2005 12:36 PM
Subject: st: Merging and counting variables

Hello Statalisters,

I've reviewed the Stata Manual and to no avail. Here is my question.

I have a master set with R county and states. County and State are appended to read, "New YorkNY", for example. I also have an association dataset that lists all national organizations and their corresponding county/state, also appended as "New YorkNY." I want to merge the datasets and find out how many associations exist in each respondent's county. For example, if R1 lives in NY, NY, I want to have a variable that will spit out "100" for the 100 organizations that exist there.

I'd appreciate your help immensely.

Thank you,
Dari E. Sylvester

Don't just search. Find. Check out the new MSN Search!

* For searches and help try:
*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index