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" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
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
michael.blasnik@verizon.net

----- Original Message ----- From: "DE S" <enchantee_76@hotmail.com>
To: <statalist@hsphsun2.harvard.edu>
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! http://search.msn.click-url.com/go/onm00200636ave/direct/01/

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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