Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: mutiple if statements


From   Ulrich Kohler <[email protected]>
To   [email protected]
Subject   Re: st: mutiple if statements
Date   Fri, 29 Jun 2007 13:11:53 +0200

Rajesh Tharyan wrote:
> I have the following file
>
> Year	id	X	 Y
> 986	6215	1	.645
> 1986	1781	1	.778
> 1986	2774	1	.819
> .....................
> 1986	817	10212	.962593
>
> The actual file has about 250 observations.
>
> I have created 25 gps based on quintiles of X and Y as follows
>
> year	Id	X	Y	      X-Quntile	Y-Quntile	Group
> 1986	817	10212	.962593	1		3		13
> 1986	2675	4930	.7089249	1		1		11
> 1986	753	4617	.7927225	1		2		12
> 1986	433	3271	.9935799	1		3		13
> 1986	2227	3076	.6346879	1		1		11
> 1986	3701	2497	1.189828	1		4		14
>
> Now I append another observation to the dataset
>
> Say
>
> Year id  X   Y
> 1986 230 62 .95
>
> How can I allocate this to the appropriate group?
>
> Note, I cannot include the new case in the first instance that I form the
> groups.

How about:

. use file1
. gen oldfile = 1
. pctile xq = x, nq(5)
. pctile yq = y, nq(5)
. append newfile
. xtile newxq = X if mi(newfile), cutpoints(xq)
. xtile newyq = Y if mi(niewfile), cutpoints(yq)
. replace group = (newxq * 10) + newyq



-- 
Ulrich Kohler
[email protected]
030/25491-361
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index