Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding a sample criteria


    Dear all,


    This is my dataset. I wanna apply a sample criteria which takes those firms whose sale in 1989 was more than 200. My sample covers the period of 1990-2010. Put differently, in order to enter this sample in 1990 firms should have more than 200 in 1989.



    conm gvkey cusip fyear sale
    AAR CORP 001004 000361105 1967 4.61
    AAR CORP 001004 000361105 1968 9.956
    AAR CORP 001004 000361105 1969 15.705
    AAR CORP 001004 000361105 1970 21.286
    AAR CORP 001004 000361105 1971 25.079
    AAR CORP 001004 000361105 1972 37.305
    AAR CORP 001004 000361105 1973 57.312
    AAR CORP 001004 000361105 1974 54.626

    Thanks in advance, i am looking forward to your answers.

    Farid.


  • #2
    Here is my dataex example.

    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str6 gvkey str58 conm double(sale fyear)

    "001002" "AAI CORP" 9.9 1960
    "001002" "AAI CORP" 8 1961
    "001002" "AAI CORP" 16.8 1962
    "001002" "AAI CORP" 17.1 1963
    "001002" "AAI CORP" 24.3 1964
    "001002" "AAI CORP" 11.7 1965
    "001002" "AAI CORP" 21.2 1966
    "001002" "AAI CORP" 37.9 1967
    "001002" "AAI CORP" 26.089 1968
    "001002" "AAI CORP" 27.939 1969
    "001002" "AAI CORP" 21.33 1970
    "001002" "AAI CORP" 22.935 1971
    "001002" "AAI CORP" 26.458 1972
    "001003" "A.A. IMPORTING CO INC" . 1980
    "001003" "A.A. IMPORTING CO INC" . 1981
    "001003" "A.A. IMPORTING CO INC" 12.748 1982
    "001003" "A.A. IMPORTING CO INC" 13.793 1983
    "001003" "A.A. IMPORTING CO INC" 13.829 1984
    "001003" "A.A. IMPORTING CO INC" 24.189 1985
    "001003" "A.A. IMPORTING CO INC" 36.308 1986
    "001003" "A.A. IMPORTING CO INC" 37.356 1987
    "001003" "A.A. IMPORTING CO INC" 32.808 1988
    "001003" "A.A. IMPORTING CO INC" 19.267 1989
    "001004" "AAR CORP" 3.821 1965
    "001004" "AAR CORP" 4.654 1966
    "001004" "AAR CORP" 4.61 1967
    "001004" "AAR CORP" 9.956 1968
    "001004" "AAR CORP" 15.705 1969
    "001004" "AAR CORP" 21.286 1970
    "001004" "AAR CORP" 25.079 1971
    "001004" "AAR CORP" 37.305 1972
    "001004" "AAR CORP" 57.312 1973
    "001004" "AAR CORP" 54.626 1974
    "001004" "AAR CORP" 65.797 1975
    "001004" "AAR CORP" 80.535 1976
    "001004" "AAR CORP" 92.82 1977
    "001004" "AAR CORP" 118.667 1978
    "001004" "AAR CORP" 130.617 1979
    "001004" "AAR CORP" 132.482 1980
    "001004" "AAR CORP" 175.924 1981
    "001004" "AAR CORP" 155.006 1982
    "001004" "AAR CORP" 177.762 1983
    "001004" "AAR CORP" 218.946 1984
    "001004" "AAR CORP" 248.012 1985
    "001004" "AAR CORP" 298.192 1986
    "001004" "AAR CORP" 347.64 1987
    "001004" "AAR CORP" 406.36 1988
    "001004" "AAR CORP" 444.875 1989
    "001004" "AAR CORP" 466.542 1990
    "001004" "AAR CORP" 422.657 1991
    "001004" "AAR CORP" 382.78 1992
    "001004" "AAR CORP" 407.754 1993
    "001004" "AAR CORP" 451.395 1994
    "001004" "AAR CORP" 504.99 1995
    "001004" "AAR CORP" 589.328 1996
    "001004" "AAR CORP" 782.123 1997
    "001004" "AAR CORP" 918.036 1998
    "001004" "AAR CORP" 1024.333 1999
    "001004" "AAR CORP" 874.255 2000
    "001004" "AAR CORP" 638.721 2001
    "001004" "AAR CORP" 606.337 2002
    "001004" "AAR CORP" 651.958 2003
    "001004" "AAR CORP" 747.848 2004
    "001004" "AAR CORP" 897.284 2005
    "001004" "AAR CORP" 1061.169 2006
    "001004" "AAR CORP" 1384.919 2007
    "001004" "AAR CORP" 1423.976 2008
    "001004" "AAR CORP" 1352.151 2009
    "001004" "AAR CORP" 1775.782 2010
    "001004" "AAR CORP" 2074.498 2011
    "001004" "AAR CORP" 2167.1 2012
    "001004" "AAR CORP" 2035 2013
    "001004" "AAR CORP" 1594.3 2014



    Here are two firms which existed in 1989. From I need to keep "AAR CORP" in my sample as its sale in 1989 was more 200, but remove other firms.

    Best regards, Farid

    Comment


    • #3
      The following code when applied to the sample data you provided in post #2 keeps all the observations for gvkey 001004 and removes all the observations for the other firms.
      Code:
      bysort gvkey (fyear): egen tokeep = max(fyear==1989 & sale>200)
      keep if tokeep

      Comment


      • #4
        Dear William,

        This code worked perfectly, thanks a lot.

        Comment

        Working...
        X