Announcement

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

  • Interpolate Values

    Good Morning,

    I am having difficulty interpolating an education percentage variable. The snapshot that I am showing below is for the state of Alabama which a small subset of a larger data set. My dataset is looking at the education percentage of college graduates between ages 18-25 with a bachelors degree from 1960 through 2013 across all 50 states. However, I only have the education percentage for every 10 years when the census was taken (1960, 1970, 1980, 1990, 2000, and 2010). I need to fill in the missing values by linear interpolation. The first step I do is:

    list, sep(0)

    +-------------+
    | year y |
    |-------------|
    1. | 1960 5.7 |
    2. | 1961 . |
    3. | 1962 . |
    4. | 1963 . |
    5. | 1964 . |
    6. | 1965 . |
    7. | 1966 . |
    8. | 1967 . |
    9. | 1968 . |
    10. | 1969 . |
    11. | 1970 7.8 |
    12. | 1971 . |
    13. | 1972 . |
    14. | 1973 . |
    15. | 1974 . |
    16. | 1975 . |
    17. | 1976 . |
    18. | 1977 . |
    19. | 1978 . |
    20. | 1979 . |
    21. | 1980 12.2 |
    22. | 1981 . |
    23. | 1982 . |
    24. | 1983 . |
    25. | 1984 . |
    26. | 1985 . |
    27. | 1986 . |
    28. | 1987 . |
    29. | 1988 . |
    30. | 1989 . |
    31. | 1990 15.7 |
    32. | 1991 . |
    33. | 1992 . |
    34. | 1993 . |
    35. | 1994 . |
    36. | 1995 . |
    37. | 1996 . |
    38. | 1997 . |
    39. | 1998 . |
    40. | 1999 . |
    41. | 2000 19 |
    42. | 2001 . |
    43. | 2002 . |
    44. | 2003 . |
    45. | 2004 . |
    46. | 2005 . |
    47. | 2006 . |
    48. | 2007 . |
    49. | 2008 . |
    50. | 2009 . |
    51. | 2010 21.9 |
    52. | 2011 . |
    53. | 2012 . |
    54. | 2013 . |
    +-------------+

    Then I use this command:

    ipolate y year, gen(y1)

    and I get the following error: type mismatch. I'm not sure what I am doing wrong and I would appreciate any helpful hints on how to correct my error. Thank you, Andrea.

  • #2
    Presumably one of your variables is string. Try

    Code:
    describe y year

    Comment


    • #3
      Hi Nick,

      Yes, you are correct. I am still kind of lost. What would be my next step?

      describe y year

      storage display value
      variable name type format label variable label
      ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      y str4 %9s y
      year int %10.0g year


      Comment


      • #4
        So, you need to

        Code:
        destring year, replace
        except that you need to worry why it is a string in the first place.

        Code:
        list year if missing(real(year))
        will show problems.

        Comment


        • #5
          Okay... so I am getting an error after I try the list year if missing(real(year))

          destring year, replace
          year already numeric; no replace


          . list year if missing(real(year))
          type mismatch
          r(109);

          Comment


          • #6
            Sorry, it's y that is string and that needs to be numeric. Stata did tell you (us) that.

            From the display in #1 it did look numeric.

            Comment


            • #7
              That solved the issue. Thank you so much for your assistance. I greatly appreciate it.

              Comment

              Working...
              X