Statalist


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

RE: st: mutiple if statements


From   "Rajesh Tharyan" <[email protected]>
To   <[email protected]>
Subject   RE: st: mutiple if statements
Date   Fri, 29 Jun 2007 17:25:43 +0100

Hi,

Thanks you so very much... when I run the program  it gives me a no
observations error (see below) ...I just cant figure out the problem!!

rajesh

****log file*******

. use file1,clear

. // Append both files from the start

. gen file = 1
. append using file2
. replace file = 0 if file == .
(1 real change made)

. // File 1
. xtile xq1 = x if file, nq(5)

. egen yq1 = xtile(y) if file, by(xq1) nq(5)
(1 missing value generated)

. // File 2
. pctile xcut = x if file, nq(5)

. xtile xq2 = x if !file, cutpoints(xcut)

. drop xcut       


. gen yq2 = .
(265 missing values generated)

. forv i=1/5 {
  2.         pctile ycut = y if file & xq1 == `i', nq(5)
  3.         xtile temp = y if !file & xq2==`i', cutpoints(ycut)
  4.         replace yq2 = temp if !file & xq2==`i'
  5.         drop temp ycut
  6. }
no observations
r(2000);

end of do-file
r(2000);

******************

 Below are two files I used

 *****file1.dta

 Year	id	x	 y
 986	6215	1	.645
 1986	1781	1	.778
 1986	2774	1	.819
 1986	6354	1	.921
 1986	6297	1	1.154
 1986	6852	1	1.218
 1986	6390	1	1.994
 1986	7241	1	2.226
 1986	6328	1	2.276
 1986	4846	1	2.432
 1986	6779	1	2.531
 1986	67	1	2.97
 1986	5452	1	3.422
 1986	232	1	3.699
 1986	6680	1	3.816
 1986	6803	1	8.242
 1986	6748	2	.8505
 1986	7420	2	.965
 1986	6003	2	1.0065
 1986	1134	2	1.0105
 1986	5138	2	1.1095
 1986	3932	2	1.1635
 1986	6280	2	1.237
 1986	2575	2	1.993
 1986	6811	2	2.411
 1986	2101	2	2.539
 1986	4658	2	2.6265
 1986	449	2	5.7535
 1986	863	3	.7213333
 1986	6398	3	.7516667
 1986	4330	3	.8473334
 1986	6751	3	.8583333
 1986	3911	3	.8786666
 1986	1393	3	.9943333
 1986	2791	3	1.095667
 1986	1020	3	1.235667
 1986	7424	3	1.242667
 1986	6254	3	1.248667
 1986	4196	3	1.988667
 1986	3176	3	2.129
 1986	6953	3	6.286667
 1986	2223	4	.65475
 1986	6220	4	.72
 1986	1050	4	.7285
 1986	3316	4	.79275
 1986	1227	4	.81325
 1986	1927	4	.9325
 1986	6893	4	1.4805
 1986	1992	4	4.23975
 1986	1725	5	.826
 1986	6216	5	.9128
 1986	581	5	.9368
 1986	3663	5	1.0186
 1986	6204	5	1.0572
 1986	6377	5	1.1318
 1986	6845	5	2.5192
 1986	541	6	.636
 1986	1769	6	.8213333
 1986	7253	6	.9143333
 1986	7079	6	1.001833
 1986	2961	6	1.006167
 1986	650	6	1.469333
 1986	4557	6	2.343167
 1986	4526	7	.8422857
 1986	7219	7	.8551429
 1986	3601	7	.9331428
 1986	2049	7	.9377143
 1986	3423	7	1.194857
 1986	6371	7	1.230286
 1986	3296	7	1.416714
 1986	4029	8	.8565
 1986	2833	8	1.04075
 1986	6051	8	1.057875
 1986	6889	8	1.111875
 1986	2520	8	1.248125
 1986	2825	8	1.493875
 1986	2834	9	.8953333
 1986	6209	9	.9325555
 1986	5355	9	1.174444
 1986	2838	9	1.243778
 1986	7220	10	.6192
 1986	1213	10	1.0426
 1986	3200	10	1.2048
 1986	6917	10	1.2685
 1986	1856	10	1.3986
 1986	2273	10	1.5251
 1986	780	11	.8487273
 1986	5530	11	.9084545
 1986	3229	11	1.124909
 1986	1422	11	1.433091
 1986	7289	11	1.535455
 1986	3011	12	.6015833
 1986	2932	13	.6307692
 1986	5696	13	.6867692
 1986	1895	13	.7826923
 1986	2764	13	.9275385
 1986	6733	14	.9395714
 1986	634	14	1.027643
 1986	6383	14	1.160286
 1986	6926	14	1.282857
 1986	6691	14	2.482214
 1986	7280	15	.5949333
 1986	1030	15	.8263333
 1986	7260	15	.9454
 1986	260	15	1.1282
 1986	447	15	1.259267
 1986	937	15	2.193
 1986	7174	15	2.418334
 1986	3606	16	.981
 1986	1090	17	.6685294
 1986	520	17	.7210588
 1986	809	17	1.131529
 1986	3306	17	1.180471
 1986	5035	18	.6151111
 1986	2829	18	.8278334
 1986	5686	19	.6185263
 1986	1404	19	.6494737
 1986	6772	19	.8598947
 1986	2650	20	1.03155
 1986	6912	20	1.26795
 1986	2258	20	1.2814
 1986	6200	21	.8549524
 1986	4021	21	1.135333
 1986	1857	21	1.243905
 1986	2221	22	.6185909
 1986	1961	22	.7391818
 1986	5162	22	.7798182
 1986	6759	22	.8664545
 1986	3662	24	.7367499
 1986	3234	24	1.114333
 1986	2756	24	1.138667
 1986	7288	25	.67036
 1986	3154	25	1.00056
 1986	3266	27	.8845555
 1986	3373	27	1.479741
 1986	7323	27	1.545296
 1986	6925	28	.9295357
 1986	4639	28	1.24175
 1986	3753	29	.9623449
 1986	1827	29	1.121621
 1986	1736	29	1.131655
 1986	2922	29	1.158
 1986	1233	30	1.248
 1986	5500	31	.6467742
 1986	1688	31	1.219968
 1986	5760	31	1.53029
 1986	1189	32	.7494687
 1986	5524	32	1.145594
 1986	784	33	.9015151
 1986	614	33	1.039606
 1986	4243	33	1.14003
 1986	2165	34	1.114
 1986	5505	35	.7846286
 1986	3337	40	.9875
 1986	94	41	1.221537
 1986	1776	42	.7180238
 1986	2361	42	4.724024
 1986	3052	43	1.23414
 1986	7043	47	1.234277
 1986	6530	49	1.226735
 1986	2810	51	.8077059
 1986	1777	52	1.259385
 1986	3785	53	1.101679
 1986	2123	54	1.119148
 1986	757	54	4.539814
 1986	5087	56	1.283143
 1986	844	59	.7798983
 1986	4599	60	1.036933
 1986	6579	60	3.429917
 1986	1831	61	1.221049
 1986	6766	62	1.260548
 1986	5252	63	1.216698
 1986	2498	64	.8532969
 1986	6250	68	.7892647
 1986	1155	69	1.269333
 1986	3261	70	.6732715
 1986	3201	70	1.1873
 1986	1039	75	.9410933
 1986	426	77	1.192559
 1986	1950	77	1.516922
 1986	9	78	1.25
 1986	5294	79	.8405949
 1986	5098	80	1.213163
 1986	390	81	.8158889
 1986	1491	81	1.023877
 1986	3649	82	.5865853
 1986	4915	83	1.280253
 1986	2666	87	.6646092
 1986	3003	90	1.021233
 1986	1965	93	1.157559
 1986	3805	93	1.224559
 1986	5263	96	2.172917
 1986	4193	105	1.084371
 1986	3393	107	.7216729
 1986	3491	107	1.164075
 1986	4614	108	1.043407
 1986	4586	110	1.181691
 1986	158	111	1.172018
 1986	2350	119	.7596639
 1986	4718	120	.8131583
 1986	3595	126	1.22446
 1986	3007	129	1.210829
 1986	5253	133	1.24279
 1986	2301	133	1.255195
 1986	7232	139	.9599856
 1986	3614	147	.6333333
 1986	1450	150	.6472933
 1986	2741	156	1.150083
 1986	7011	160	.9860312
 1986	5305	163	1.184429
 1986	4572	166	1.283777
 1986	2365	166	5.42053
 1986	1019	170	.6333706
 1986	5216	181	.807453
 1986	657	182	1.149483
 1986	1971	184	.6699783
 1986	3489	184	1.269315
 1986	4546	192	1.194411
 1986	4440	198	.7549646
 1986	6653	208	1.27563
 1986	3843	217	.9751152
 1986	5255	220	1.002273
 1986	3402	226	.5967788
 1986	2477	238	.6786134
 1986	3113	244	.5905738
 1986	6047	247	.9202713
 1986	2687	257	1.103988
 1986	4552	261	1.132889
 1986	1555	263	.7302281
 1986	5405	275	.6592727
 1986	674	283	.7971731
 1986	5689	290	1.192352
 1986	4560	292	1.203819
 1986	6528	297	.7919192
 1986	6726	297	1.456229
 1986	1397	332	.7204819
 1986	6654	334	1.119761
 1986	7198	339	.6253687
 1986	1755	343	1.214857
 1986	97	343	1.284787
 1986	5077	348	1.14381
 1986	4744	368	1.4875
 1986	938	389	.8467866
 1986	4256	453	.6399558
 1986	798	462	.5989178
 1986	424	487	.826078
 1986	2407	502	.848008
 1986	3250	540	1.190185
 1986	1825	568	.7835158
 1986	2304	622	1.020257
 1986	2998	657	.8304414
 1986	3687	754	1.168568
 1986	1313	949	1.221496
 1986	2303	1144	.7687937
 1986	6792	1175	1.009532
 1986	4345	1574	.9343075
 1986	98	1835	.7093188
 1986	5290	2173	1.52416
 1986	3701	2497	1.189828
 1986	2227	3076	.6346879
 1986	433	3271	.9935799
 1986	753	4617	.7927225
 1986	2675	4930	.7089249
 1986	817	10212	.962593


 ***newfile.dta
 Year	id	X	 Y
 986	6215	1	.645
 1986	1781	1	.778
 1986	2774	1	.819
 1986	6354	1	.921
 1986	6297	1	1.154
 1986	6852	1	1.218
 1986	6390	1	1.994
 1986	7241	1	2.226
 1986	6328	1	2.276
 1986	4846	1	2.432
 1986	6779	1	2.531
 1986	67	1	2.97
 1986	5452	1	3.422
 1986	232	1	3.699
 1986	6680	1	3.816
 1986	6803	1	8.242
 1986	6748	2	.8505
 1986	7420	2	.965
 1986	6003	2	1.0065
 1986	1134	2	1.0105
 1986	5138	2	1.1095
 1986	3932	2	1.1635
 1986	6280	2	1.237
 1986	2575	2	1.993
 1986	6811	2	2.411
 1986	2101	2	2.539
 1986	4658	2	2.6265
 1986	449	2	5.7535
 1986	863	3	.7213333
 1986	6398	3	.7516667
 1986	4330	3	.8473334
 1986	6751	3	.8583333
 1986	3911	3	.8786666
 1986	1393	3	.9943333
 1986	2791	3	1.095667
 1986	1020	3	1.235667
 1986	7424	3	1.242667
 1986	6254	3	1.248667
 1986	4196	3	1.988667
 1986	3176	3	2.129
 1986	6953	3	6.286667
 1986	2223	4	.65475
 1986	6220	4	.72
 1986	1050	4	.7285
 1986	3316	4	.79275
 1986	1227	4	.81325
 1986	1927	4	.9325
 1986	6893	4	1.4805
 1986	1992	4	4.23975
 1986	1725	5	.826
 1986	6216	5	.9128
 1986	581	5	.9368
 1986	3663	5	1.0186
 1986	6204	5	1.0572
 1986	6377	5	1.1318
 1986	6845	5	2.5192
 1986	541	6	.636
 1986	1769	6	.8213333
 1986	7253	6	.9143333
 1986	7079	6	1.001833
 1986	2961	6	1.006167
 1986	650	6	1.469333
 1986	4557	6	2.343167
 1986	4526	7	.8422857
 1986	7219	7	.8551429
 1986	3601	7	.9331428
 1986	2049	7	.9377143
 1986	3423	7	1.194857
 1986	6371	7	1.230286
 1986	3296	7	1.416714
 1986	4029	8	.8565
 1986	2833	8	1.04075
 1986	6051	8	1.057875
 1986	6889	8	1.111875
 1986	2520	8	1.248125
 1986	2825	8	1.493875
 1986	2834	9	.8953333
 1986	6209	9	.9325555
 1986	5355	9	1.174444
 1986	2838	9	1.243778
 1986	7220	10	.6192
 1986	1213	10	1.0426
 1986	3200	10	1.2048
 1986	6917	10	1.2685
 1986	1856	10	1.3986
 1986	2273	10	1.5251
 1986	780	11	.8487273
 1986	5530	11	.9084545
 1986	3229	11	1.124909
 1986	1422	11	1.433091
 1986	7289	11	1.535455
 1986	3011	12	.6015833
 1986	2932	13	.6307692
 1986	5696	13	.6867692
 1986	1895	13	.7826923
 1986	2764	13	.9275385
 1986	6733	14	.9395714
 1986	634	14	1.027643
 1986	6383	14	1.160286
 1986	6926	14	1.282857
 1986	6691	14	2.482214
 1986	7280	15	.5949333
 1986	1030	15	.8263333
 1986	7260	15	.9454
 1986	260	15	1.1282
 1986	447	15	1.259267
 1986	937	15	2.193
 1986	7174	15	2.418334
 1986	3606	16	.981
 1986	1090	17	.6685294
 1986	520	17	.7210588
 1986	809	17	1.131529
 1986	3306	17	1.180471
 1986	5035	18	.6151111
 1986	2829	18	.8278334
 1986	5686	19	.6185263
 1986	1404	19	.6494737
 1986	6772	19	.8598947
 1986	2650	20	1.03155
 1986	6912	20	1.26795
 1986	2258	20	1.2814
 1986	6200	21	.8549524
 1986	4021	21	1.135333
 1986	1857	21	1.243905
 1986	2221	22	.6185909
 1986	1961	22	.7391818
 1986	5162	22	.7798182
 1986	6759	22	.8664545
 1986	3662	24	.7367499
 1986	3234	24	1.114333
 1986	2756	24	1.138667
 1986	7288	25	.67036
 1986	3154	25	1.00056
 1986	3266	27	.8845555
 1986	3373	27	1.479741
 1986	7323	27	1.545296
 1986	6925	28	.9295357
 1986	4639	28	1.24175
 1986	3753	29	.9623449
 1986	1827	29	1.121621
 1986	1736	29	1.131655
 1986	2922	29	1.158
 1986	1233	30	1.248
 1986	5500	31	.6467742
 1986	1688	31	1.219968
 1986	5760	31	1.53029
 1986	1189	32	.7494687
 1986	5524	32	1.145594
 1986	784	33	.9015151
 1986	614	33	1.039606
 1986	4243	33	1.14003
 1986	2165	34	1.114
 1986	5505	35	.7846286
 1986	3337	40	.9875
 1986	94	41	1.221537
 1986	1776	42	.7180238
 1986	2361	42	4.724024
 1986	3052	43	1.23414
 1986	7043	47	1.234277
 1986	6530	49	1.226735
 1986	2810	51	.8077059
 1986	1777	52	1.259385
 1986	3785	53	1.101679
 1986	2123	54	1.119148
 1986	757	54	4.539814
 1986	5087	56	1.283143
 1986	844	59	.7798983
 1986	4599	60	1.036933
 1986	6579	60	3.429917
 1986	1831	61	1.221049
 1986	6766	62	1.260548
 1986	5252	63	1.216698
 1986	2498	64	.8532969
 1986	6250	68	.7892647
 1986	1155	69	1.269333
 1986	3261	70	.6732715
 1986	3201	70	1.1873
 1986	1039	75	.9410933
 1986	426	77	1.192559
 1986	1950	77	1.516922
 1986	9	78	1.25
 1986	5294	79	.8405949
 1986	5098	80	1.213163
 1986	390	81	.8158889
 1986	1491	81	1.023877
 1986	3649	82	.5865853
 1986	4915	83	1.280253
 1986	2666	87	.6646092
 1986	3003	90	1.021233
 1986	1965	93	1.157559
 1986	3805	93	1.224559
 1986	5263	96	2.172917
 1986	4193	105	1.084371
 1986	3393	107	.7216729
 1986	3491	107	1.164075
 1986	4614	108	1.043407
 1986	4586	110	1.181691
 1986	158	111	1.172018
 1986	2350	119	.7596639
 1986	4718	120	.8131583
 1986	3595	126	1.22446
 1986	3007	129	1.210829
 1986	5253	133	1.24279
 1986	2301	133	1.255195
 1986	7232	139	.9599856
 1986	3614	147	.6333333
 1986	1450	150	.6472933
 1986	2741	156	1.150083
 1986	7011	160	.9860312
 1986	5305	163	1.184429
 1986	4572	166	1.283777
 1986	2365	166	5.42053
 1986	1019	170	.6333706
 1986	5216	181	.807453
 1986	657	182	1.149483
 1986	1971	184	.6699783
 1986	3489	184	1.269315
 1986	4546	192	1.194411
 1986	4440	198	.7549646
 1986	6653	208	1.27563
 1986	3843	217	.9751152
 1986	5255	220	1.002273
 1986	3402	226	.5967788
 1986	2477	238	.6786134
 1986	3113	244	.5905738
 1986	6047	247	.9202713
 1986	2687	257	1.103988
 1986	4552	261	1.132889
 1986	1555	263	.7302281
 1986	5405	275	.6592727
 1986	674	283	.7971731
 1986	5689	290	1.192352
 1986	4560	292	1.203819
 1986	6528	297	.7919192
 1986	6726	297	1.456229
 1986	1397	332	.7204819
 1986	6654	334	1.119761
 1986	7198	339	.6253687
 1986	1755	343	1.214857
 1986	97	343	1.284787
 1986	5077	348	1.14381
 1986	4744	368	1.4875
 1986	938	389	.8467866
 1986	4256	453	.6399558
 1986	798	462	.5989178
 1986	424	487	.826078
 1986	2407	502	.848008
 1986	3250	540	1.190185
 1986	1825	568	.7835158
 1986	2304	622	1.020257
 1986	2998	657	.8304414
 1986	3687	754	1.168568
 1986	1313	949	1.221496
 1986	2303	1144	.7687937
 1986	6792	1175	1.009532
 1986	4345	1574	.9343075
 1986	98	1835	.7093188
 1986	5290	2173	1.52416
 1986	3701	2497	1.189828
 1986	2227	3076	.6346879
 1986	433	3271	.9935799
 1986	753	4617	.7927225
 1986	2675	4930	.7089249
 1986	817	10212	.962593

 *****file2.dta

 year	id	x	y
 1986	203	62	.95


*
*   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