I want to split the data in two files containing observations with specific IDs. I am giving an example of only 18 observations.
copy starting from the next line ---------- ------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int id str9 date int var1 byte(var2 var3) str4 var4 str1 var5 1003 "31-Jul-86" 1986 2 1 "INDL" "C" 1003 "31-Oct-86" 1986 3 1 "INDL" "C" 1003 "31-Jan-87" 1986 4 1 "INDL" "C" 1003 "30-Apr-87" 1987 1 1 "INDL" "C" 1126 "31-Jul-87" 1987 2 1 "INDL" "C" 1126 "31-Oct-87" 1987 3 1 "INDL" "C" 1126 "31-Jan-88" 1987 4 1 "INDL" "C" 3298 "30-Apr-88" 1988 1 1 "INDL" "C" 3298 "31-Jul-88" 1988 2 1 "INDL" "C" 3298 "31-Oct-88" 1988 3 1 "INDL" "C" 3677 "31-Jan-89" 1988 4 1 "INDL" "C" 3677 "30-Apr-89" 1989 1 1 "INDL" "C" 5674 "31-Jul-89" 1989 2 1 "INDL" "C" 5674 "31-Oct-89" 1989 3 1 "INDL" "C" 5674 "31-Jan-90" 1989 4 1 "INDL" "C" 6666 "30-Apr-90" 1990 1 1 "INDL" "C" 6666 "31-Jul-90" 1990 2 1 "INDL" "C" end
I used simple commands for this example like
Drop if id == 1003
Drop if id == 6666
After dropping observations, I saved rest of the data set with different name. Then in second step I did the same with other observations and saved the rest. Thus making two files.
Is there any other way to do the same because my actual data set consists of around a million of observations with around 15,000 such like IDs??
Any advice please !! I am new to stata and I hope that i explained the query properly!
Thanks
0 Response to Splitting a data set with specific IDs
Post a Comment