Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: st: RE: identifyng records in a group that have a field with nearby values from another group


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   AW: st: RE: identifyng records in a group that have a field with nearby values from another group
Date   Thu, 8 Oct 2009 14:20:43 +0200

<> 

Well, I gave the example that you requested, but the code produces all
relevant information. You simply have to call it up:

*************
su order if foreign, mean
forv i= `r(min)'/`r(max)'{
 	di in r _n(2) "Results for: " make[`i']
	l make price if !fo & group`i'
}
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Michael
McCulloch
Gesendet: Mittwoch, 7. Oktober 2009 23:12
An: [email protected]
Betreff: Re: st: RE: identifyng records in a group that have a field with
nearby values from another group

Thanks Martin. This code produces price groups within levels of range  
-200 to +200 from the baseline "foreign" example I suggested, which  
was $4296, but what I'm hoping to achieve is that same grouping for  
each one "foreign" to all "domestic" that are priced within -200 to  
+200 of that one car.

.. list foreign make price if group53==1, clean noobs
foreign	make	price	
Domestic	Chev. Monza	3,667	
Domestic	AMC Spirit	3,799	
Domestic	Merc. Bobcat	3,829	
Foreign	Toyota Corolla	3,748	
Foreign	Subaru	3,798	
Foreign	Renault Le Car	3,895


On Oct 7, 2009, at 1:08 PM, Martin Weiss wrote:

>
> <>
>
> **************
> sysuse auto, clear
> sort foreign price
> gen order=_n
> su order if foreign, mean
> forv i= `r(min)'/`r(max)'{
> gen byte group`i'=abs(price-price[`i'])<=200
> }
> l make price if !fo & group57
> **************
>
>
> HTH
> Martin
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Michael  
> McCulloch
> Sent: Mittwoch, 7. Oktober 2009 21:33
> To: Statalist Statalist
> Subject: st: identifyng records in a group that have a field with  
> nearby
> values from another group
>
> Hello,
> I have a dataset with two groups, for example "foreign" and "domestic"
> in the auto dataset.
> For example:
> 	sysuse auto, clear
> 	sort foreign price
> 	list foreign make price
>
> My question is, how to identify "domestic" cars that are within $200
> in price from each "foreign" car, and create another variable called
> "group" that mark these sets?
>
> In this case, that would be:
> 	Foreign   Fiat Strada        	4,296
> 	Domestic	AMC Concord			4,099
>  	Domestic	Pont. Sunbird			4,172
>  	Domestic	Olds Omega			4,181
>  	Domestic	Ford Mustang			4,187
>  	Domestic	Olds Starfire			4,195
>  	Domestic	Ford Fiesta			4,389
>  	Domestic	Pont. Phoenix			4,424
>  	Domestic	Plym. Champ			4,425
>  	Domestic	Buick Opel			4,453
>  	Domestic	Plym. Horizon			4,482	
> 	
>
>
> Michael McCulloch, LAc MPH PhD
> Pine Street Foundation
> 124 Pine Street
> San Anselmo, CA 94960-2674
> tel:	415-407-1357
> fax: 	206-338-2391
> [email protected]
>
>
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/



Michael McCulloch, LAc MPH PhD
Pine Street Foundation
124 Pine Street
San Anselmo, CA 94960-2674
tel:	415-407-1357
fax: 	206-338-2391
[email protected]







*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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