Dear All
I would like to check whether the values contained in the variable id, correspond to those in id1. In case any value in id is not included in id1 I need have a new variable that spots such a difference.
here an example
input int(id id1)
2831 2965
2831 3509
2832 2838
2832 3230
2833 3042
2833 3187
2834 2888
2834 3189
2835 3265
2836 2850
2836 3156
2837 2847
2837 3034
2838 2842
2838 2857
2839 2904
2839 3611
2840 3090
2840 3308
2841 2845
2842 2871
2843 2844
2843 2892
2844 3535
2845 3143
2846 2841
2846 3431
2847 3062
2848 2881
2849 3307
2849 3603
2850 3400
2851 2905
2851 3244
2852 2854
2852 2869
2853 2877
2853 3416
2854 3659
2855 2854
2855 3230
2856 2854
2856 3125
2857 2845
2857 3503
2858 3655
2859 2936
2860 3154
2861 2885
2861 3619
end
[/CODE]
I tried this:
but returns all 0, which is not the case.
Anyone can help?
Thanks
Federica
I would like to check whether the values contained in the variable id, correspond to those in id1. In case any value in id is not included in id1 I need have a new variable that spots such a difference.
here an example
input int(id id1)
2831 2965
2831 3509
2832 2838
2832 3230
2833 3042
2833 3187
2834 2888
2834 3189
2835 3265
2836 2850
2836 3156
2837 2847
2837 3034
2838 2842
2838 2857
2839 2904
2839 3611
2840 3090
2840 3308
2841 2845
2842 2871
2843 2844
2843 2892
2844 3535
2845 3143
2846 2841
2846 3431
2847 3062
2848 2881
2849 3307
2849 3603
2850 3400
2851 2905
2851 3244
2852 2854
2852 2869
2853 2877
2853 3416
2854 3659
2855 2854
2855 3230
2856 2854
2856 3125
2857 2845
2857 3503
2858 3655
2859 2936
2860 3154
2861 2885
2861 3619
end
[/CODE]
I tried this:
Code:
gen check=0 levelsof id, local (ids) levelsof id1 , local (id1s) foreach id in `ids'{ foreach id1 in `id1s'{ replace check=1 if "`ids'"=="`id1s'" } }
Anyone can help?
Thanks
Federica
Comment