Dear Statalist,

I am running into a problem. First of all, I have a panel dataset consisting of 10 waves and I use Stata 16.1.
I want to compile my dataset in such a manner, that I am only left with people who have got a child somewhere in the 10 waves. An example of my dataset is as follows:

Code:
 input float wave long(pidp hidp) byte(pno jbstat lnprnt marstat sex_dv) int(age_dv doby_dv) long ppid byte scghq1_dv double sf12mcs_dv byte(racel_dv father nchild pregout1 pregout2 pregout3) double fimnnet_dv float(gotABaby gotTwinOrTriplet)
 4   22445 280942006 5  2 -8  1 2 27 1984        -8 -8                 -8  1 -8 -8 -8 -8 -8               1140 0 .
 5   22445 279255608 5  2 -8  1 2 28 1984        -8 29              30.22  1 -8 -8 -8 -8 -8 1602.6700439453125 0 .
 6   22445 278664010 3  2 -8  1 2 29 1984        -8 25              32.59  1 -8 -8 -8 -8 -8               2012 0 .
 7   22445 278447092 1  2 -8  1 2 30 1984        -8 19              29.57  1 -8 -8  4 -8 -8               1840 0 .
 8   22445 278092814 1  5 -8  1 2 31 1984        -8 15              39.03  1 -8 -8  1 -8 -8  2089.699951171875 1 .
 9   22445 277344816 1  2 -8  2 2 33 1984        -8 11              46.08  1 -8 -8 -8 -8 -8  1289.699951171875 0 .
10   22445 277059218 1  2 -8  2 2 33 1984 277059298 11              33.83  1 -8 -8  3 -8 -8  1289.699951171875 0 .
 4   29925 622866406 3  6  2 -7 2 35 1977        -8 -7                 -7  1 -7 -7 -7 -7 -7                  0 0 .
 6   29925 620547610 1  1 -8  4 2 37 1977        -8 11              35.67  1 -8 -8  1  1 -8    2378.4599609375 0 1
 7   29925 620316412 1  1 -8  5 2 38 1977        -8 16              28.16  1 -8 -8 -8 -8 -8    2076.8701171875 0 .
 8   29925 619935614 1  2 -8  5 2 39 1977        -8 12              46.08  1 -8 -8 -8 -8 -8     2811.669921875 0 .
 9   29925 619024416 1  2 -8  5 2 40 1977        -8  9              41.06  1 -8 -8 -8 -8 -8  2904.530029296875 0 .
10   29925 618630018 1  2 -8  5 2 41 1977        -8 17              37.69  1 -8 -8 -8 -8 -8               2760 0 .
 7   76165 142378412 1  2 -8  2 2 32 1982 142378492 10              46.94  1 -8 -8 -8 -8 -8 1804.1700439453125 0 .
 8   76165 142235614 1  2 -8  2 2 33 1982 142378492 14              46.45  1 -8 -8  4 -8 -8     2208.330078125 0 .
 9   76165 141657616 1  2 -8  2 2 34 1982 142378492  8              62.49  1 -8 -8  2 -8 -8     3378.669921875 1 .
10   76165 141460418 1  2 -8  2 2 35 1982 142378492 11              51.24  1 -8 -8 -8 -8 -8               2862 0 .
 7  223725 619140012 3  2 -8 -7 1 40 1975        -8 -7                 -7  1 -7 -7 -7 -7 -7  869.2899780273438 0 .
 8  223725 618772814 1  2 -8 -7 1 41 1975        -8 -7                 -7  1 -7 -7 -7 -7 -7 1020.2999877929688 0 .
 2  280165 783876802 2  2  1  1 2 31 1979        -8 -8                 -8  1 -8 -8 -8 -8 -8            2165.75 0 .
 3  280165 759532804 2  2  1 -7 2 32 1979        -8 -7                 -7  1 -7 -7 -7 -7 -7  2189.889892578125 0 .
 4  280165 758492406 2  2  1 -7 2 33 1979        -8 -7                 -7  1 -7 -7 -7 -7 -7     2183.080078125 0 .
 5  280165 756833208 2  2 -8  1 2 34 1979        -8 24              35.62  1 -8 -8 -8 -8 -8     2324.169921875 0 .
 6  280165 756200810 2  2 -8 -7 2 35 1979 756200970 -7                 -7  1 -7 -7 -7 -7 -7  2085.639892578125 0 .
 7  280165 755847212 1  2 -8  1 2 36 1979 756200970 17               28.5  1 -8 -8 -8 -8 -8  2289.699951171875 0 .
 8  280165 755643214 1  2 -8  2 2 37 1979 756200970  9              48.77  1 -8 -8 -8 -8 -8  2352.699951171875 0 .
 9  280165 754793216 1  2 -8  2 2 38 1979 756200970  7              52.43  1 -8 -8 -8 -8 -8  2317.699951171875 0 .
10  280165 754371618 1  2 -8  2 2 39 1979 756200970  7              52.53  1 -8 -8 -8 -8 -8  3093.699951171875 0 .
 6  333205 416683610 3  2 -8  1 2 24 1990        -8  5               54.2  1 -8 -8 -8 -8 -8 1604.1700439453125 0 .
 7  333205 416466012 3  2 -8  1 2 25 1990        -8  6              50.65  1 -8 -8 -8 -8 -8 1525.8299560546875 0 .
 8  333205 415935614 1  2 -8  1 2 26 1990        -8  7              65.95  1 -8 -8 -8 -8 -8 1558.3299560546875 0 .
 9  333205 415106696 1  2 -8  1 2 27 1990        -8  7               54.2  1 -8 -8 -8 -8 -8 1658.3299560546875 0 .
10  333205 414800018 1  2 -8  1 2 28 1990 414800098  7              68.33  1 -8 -8 -8 -8 -8 1741.6600341796875 0 .
 4  387605 349690006 3  3 -8  1 2 24 1988        -8 18              39.89  1 -8 -8  3 -8 -8 .07999999821186066 0 .
 5  387605 348044408 3  3 -8  1 2 25 1988        -8 22              22.31  1 -8 -8  3 -8 -8 .17000000178813934 0 .
 6  387605 347486810 3  3 -8  1 2 26 1988        -8 22              19.88  1 -8 -8 -8 -8 -8  309.8299865722656 0 .
 7  387605 347194412 3  2 -8  1 2 27 1988        -8  6              37.02  1 -8 -8 -8 -8 -8  866.6699829101563 0 .
 9  469205 415059096 1  5  1  1 2 27 1990 415059176 13 58.300000000000004  1 -8 -8 -8 -8 -8   1853.31005859375 0 .
10  469205 414738818 1  2 -8  1 2 28 1990 415059176 12              45.56  1 -8 -8 -8 -8 -8  708.6699829101563 0 .
 3  541285 146730404 4  2 -8 -7 1 25 1985        -8 -7                 -7  1 -7 -7 -7 -7 -7  593.9000244140625 0 .
 4  541285 145989206 4  3 -8 -7 1 26 1985        -8 -7                 -7  1 -7 -7 -7 -7 -7                  0 0 .
 5  541285 144146408 3  3 -8 -7 1 27 1985        -8 -7                 -7  1 -7 -7 -7 -7 -7                  0 0 .
 6  541285 143384810 2  1 -8  1 1 28 1985        -8 18              24.76  1  2 -8 -8 -8 -8  1126.800048828125 0 .
 3  541965 146730404 3  2 -8 -7 2 23 1987        -8 -7                 -7  1 -7 -7 -7 -7 -7  332.6700134277344 0 .
 4  599765 214798406 3  2 -8 -7 2 25 1986        -8 -7                 -7  1 -7 -7 -7 -7 -7  1644.489990234375 0 .
 5  599765 213057608 3  2 -8  1 2 26 1986        -8  7              60.29  1 -8 -8 -8 -8 -8 1769.3399658203125 0 .
 9  599765 211282816 1  2 -8  1 2 30 1986        -8  6              54.74  1 -8 -8 -8 -8 -8               2084 0 .
10  599765 210881618 1  2 -8  1 2 31 1986        -8  7              58.15  1 -8 -8 -8 -8 -8  2353.639892578125 0 .
 3  665045 215192804 4  2 -8  1 1 29 1981        -8 -8                 -8  1  2 -8 -8 -8 -8  563.3300170898438 0 .
 4  665045 214812006 4  2 -8  1 1 30 1981        -8 -8                 -8  1  2 -8 -8 -8 -8                598 0 .
 5  665045 213071208 4  2 -8  1 1 31 1981        -8  7              52.82  1  2 -8 -8 -8 -8  652.1699829101563 0 .
 6  665045 212588410 4  2 -8  1 1 32 1981        -8 10              50.14  1  2 -8 -8 -8 -8                460 0 .
 8  665045 212064814 4  2 -8  1 1 34 1981        -8  7 57.160000000000004  1  2 -8 -8 -8 -8  772.4199829101563 0 .
10  665045 210902018 1  2 -8  1 1 36 1981        -8  7              53.21  1  2 -8 -8 -8 -8              253.5 0 .
 9  732365 619371216 1  8 -8  1 1 32 1985        -8 35              12.81  1  2 -8 -8 -8 -8 1110.4200439453125 0 .
10  732365 618949618 1  8 -8  1 1 33 1985        -8 22              11.09  1  2 -8 -8 -8 -8                845 0 .
10  760925 210514418 1  8 -8  1 1 37 1981        -8 -8                 -8 -9  2 -8 -8 -8 -8 1252.3299560546875 0 .
 4  813285 553343206 3  2 -8 -7 1 42 1970        -8 -7                 -7  1 -7 -7 -7 -7 -7  595.8200073242188 0 .
 5  813285 551758808 3  2 -8 -7 1 43 1970        -8 -7                 -7  1 -7 -7 -7 -7 -7   1628.77001953125 0 .
 6  813285 551180810 3  2 -8 -7 1 44 1970        -8 -7                 -7  1 -7 -7 -7 -7 -7   1691.18994140625 0 .
 7  813285 550902012 3  2 -8 -7 1 45 1970        -8 -7                 -7  1 -7 -7 -7 -7 -7 1693.3900146484375 0 .
 8  813285 550623214 1  2 -8 -7 1 46 1970        -8 -7                 -7  1 -7 -7 -7 -7 -7 1691.8900146484375 0 .
 7  850005 211922012 2  2 -8 -7 1 26 1988        -8 -7                 -7  1 -7 -7 -7 -7 -7    1071.2900390625 0 .
 2  987365 170639202 2  7 -8 -7 2 20 1989        -8 -7                 -7 -9 -7 -7 -7 -7 -7              652.5 0 .
 3  987365 146472004 2  2 -8 -7 2 21 1989        -8 -7                 -7 -9 -7 -7 -7 -7 -7 497.42999267578125 0 .
 2 1114525 170802402 7  2  1 -7 1 36 1973        -8 -7                 -7  1 -7 -7 -7 -7 -7   2247.02001953125 0 .
 2 1126765 442856802 2  3 -8  1 2 21 1989        -8 -8                 -8  1 -8 -8 -8 -8 -8                  0 0 .
 2 1558565 852386802 3  7 -8  1 2 17 1993        -8 10              27.94  1 -8 -8 -8 -8 -8                130 0 .
 3 1558565 828349484 1  7 -8  1 2 18 1993        -8  5              48.43  1 -8 -8 -8 -8 -8                702 0 .
 6 1587125 619704410 2  8 -8  1 2 48 1965        -8 26                 16 13 -8 -8 -8 -8 -8  307.6700134277344 0 .
 7 1587125 619493612 2  1 -8  1 2 50 1965        -8 12              45.81 13 -8 -8 -8 -8 -8  3390.820068359375 0 .
 8 1587125 619112814 1  1 -8  1 2 50 1965        -8 12              46.22 13 -8 -8 -8 -8 -8    4303.5498046875 0 .
 9 1587125 618269616 1  2 -8  1 2 51 1965        -8 12              43.37 13 -8 -8 -8 -8 -8   2802.27001953125 0 .
10 1587125 617895618 1  1 -8  1 2 52 1965        -8 23              41.93 13 -8 -8 -8 -8 -8  3034.159912109375 0 .
 8 1697285 211473214 3  2 -8  5 1 43 1972        -8 14              37.03  1  2 -8 -8 -8 -8               1171 0 .
 9 1697285 210766016 1  2 -8  5 1 44 1972        -8 10              36.37  1  2 -8 -8 -8 -8               1142 0 .
10 1697285 210364818 1  2 -8  5 1 45 1972        -8 10 31.400000000000002  1  2 -8 -8 -8 -8               1200 0 .
 5 1731965 484275608 5  2 -8  1 1 22 1990        -8  7 49.410000000000004  1  2 -8 -8 -8 -8 1958.3299560546875 0 .
 2 1833965 782088402 3  1 -8  1 1 45 1965        -8 15 28.740000000000002  1 -8 -8 -8 -8 -8 1580.6199951171875 0 .
 3 1833965 757615204 3  2 -8  1 1 46 1965        -8  8 37.910000000000004  1  2 -8 -8 -8 -8   1329.81005859375 0 .
 4 1833965 756846806 3  2  1 -7 1 47 1965        -8 -7                 -7  1 -7 -7 -7 -7 -7    1506.2099609375 0 .
 5 1833965 755412008 2  2 -8  1 1 48 1965        -8 26 22.650000000000002  1  2 -8 -8 -8 -8            1582.25 0 .
 6 1833965 754766010 2  1 -8  1 1 49 1965        -8 20              25.16  1  2 -8 -8 -8 -8  972.3400268554688 0 .
 7 1833965 754494012 1  2 -8  1 1 50 1965        -8  7 49.870000000000005  1  2 -8 -8 -8 -8 1704.1700439453125 0 .
 8 1833965 754310414 1 97 -8  1 1 51 1965        -8 29              24.22  1  2 -8 -8 -8 -8 1201.6700439453125 0 .
 9 1833965 753508016 1  2 -8  1 1 52 1965        -8 12 42.410000000000004  1  2 -8 -8 -8 -8               1000 0 .
 6 2067205  74759210 4  3 -8  1 1 25 1988        -8 22 29.150000000000002  1  2 -8 -8 -8 -8                  0 0 .
 7 2067205  74596012 3  2 -8  1 1 26 1988        -8 11              33.07  1  2 -8 -8 -8 -8  425.2300109863281 0 .
 7 2270525 824894412 3  6  1  1 2 18 1997        -8 10              41.71  1 -8 -8 -8 -8 -8   1077.77001953125 0 .
 8 2270525 824548294 1  6 -8  1 2 19 1997 824548414 15              50.19  1 -8 -8  4 -8 -8  877.7000122070313 0 .
 9 2270525 823677216 1  6 -8  1 2 20 1997 824548414 23              25.38  1 -8 -8  1 -8 -8  1483.030029296875 1 .
 3 2292285 556233204 6  8  4 -7 1 36 1975 548026285 -7                 -7  1 -7 -7 -7 -7 -7                146 0 .
 4 2292285 554988806 6  8  4 -7 1 36 1975 548026285 -7                 -7  1 -7 -7 -7 -7 -7  342.3299865722656 0 .
 5 2297045 416228008 4  7 -8 -7 1 16 1997        -8 -7                 -7  1 -7 -7 -7 -7 -7                  0 0 .
 6 2297045 415622810 3  2 -8  1 1 17 1997        -8  3 50.050000000000004  1 -8 -8 -8 -8 -8                175 0 .
 2 2401085 239339602 4  2 -8 -7 2 26 1983        -8 -7                 -7  1 -7 -7 -7 -7 -7  233.3300018310547 0 .
 2 2539125 103904002 5  2 -8  1 2 22 1987        -8 20              36.99  1 -8 -8 -8 -8 -8  628.3300170898438 0 .
 2 2626845 852033202 4  3 -8  1 1 32 1978 818504445  8              56.47  1 -8 -8 -8 -8 -8  281.6700134277344 0 .
 4 2626845 827220006 1  2 -8  1 1 34 1978 818504445 13              48.57  1  2 -8 -8 -8 -8               1025 0 .
 6 2626845 824445610 1  2 -8  1 1 36 1978 818504445 11               54.1  1  2 -8 -8 -8 -8                980 0 .
end
I'm not sure if I used the right format, but the columns that are relevant is the first column (wave), second column (pidp, cross-sectional person-identifier), and second-to-last column (gotABaby).
I did manage to create a gotABaby dummy variable (which is 1 in the periods that an individual got a baby). What I didn't manage to do is the following: I only want to keep observations of individuals who got a baby and I also want to observe these individuals in all other waves(in which they did not have a child).

Thanks in advance and kind regards,

Vincent van Marrewijk