Announcement

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

  • Using dataex

    This is text before any code: I am going to get a subset of records from auto.dta using dataex and then check for outliers.
    Code:
    sysuse auto
    randomtag, count(10) ge(mark)
    dataex if mark
    Following is the output from dataex in the results window, which I will paste in my do file editor and run the code to generate a dataset of 10 random rows from auto.dta:
    Code:
    clear
    input float id str18 make int(price mpg rep78) float headroom int(trunk weight length turn displacement) float gear_ratio byte(foreign mark)
     6 "Buick LeSabre"  5788 18 3   4 21 3670 218 43 231 2.73 0 1
     8 "Buick Regal"    5189 20 3   2 16 3280 200 42 196 2.93 0 1
    12 "Cad. Eldorado" 14500 14 2 3.5 16 3900 204 43 350 2.19 0 1
    29 "Merc. Bobcat"   3829 22 4   3  9 2580 169 39 140 2.73 0 1
    34 "Merc. Zephyr"   3291 20 3 3.5 17 2830 195 43 140 3.08 0 1
    38 "Olds Delta 88"  4890 18 4   4 20 3690 218 42 231 2.73 0 1
    51 "Pont. Phoenix"  4424 19 . 3.5 13 3420 203 43 231 3.08 0 1
    57 "Datsun 210"     4589 35 5   2  8 2020 165 32  85  3.7 1 1
    71 "VW Diesel"      5397 41 5   3 15 2040 155 35  90 3.78 1 1
    73 "VW Scirocco"    6850 25 4   2 16 1990 156 36  97 3.78 1 1
    end
    label values foreign origin
    label def origin 0 "Domestic", modify
    label def origin 1 "Foreign", modify
    Next, check for outliers:
    Code:
    su weight, de
    ge zweight = (weight-r(mean))/(r(sd)/sqrt(r(N)))
    count if zweight >= 3 & zweight < .
    count if zweight <= 3
    Posting now; fingers crossed.

  • #2
    Where do I paste the output from results window please; in [CODE/CODE] segment?

    Comment


    • #3
      This is text before any code: I am going to get a subset of records from auto.dta using dataex and then check for outliers.
      Code:
      sysuse auto
      randomtag, count(10) ge(mark)
      dataex if mark
      Following is the output from dataex in the results window, which I will paste in my do file editor and run the code to generate a dataset of 10 random rows from auto.dta:
      Code:
      clear
      input float id str18 make int(price mpg rep78) float headroom int(trunk weight length turn displacement) float gear_ratio byte(foreign mark)
       6 "Buick LeSabre"  5788 18 3   4 21 3670 218 43 231 2.73 0 1
       8 "Buick Regal"    5189 20 3   2 16 3280 200 42 196 2.93 0 1
      12 "Cad. Eldorado" 14500 14 2 3.5 16 3900 204 43 350 2.19 0 1
      29 "Merc. Bobcat"   3829 22 4   3  9 2580 169 39 140 2.73 0 1
      34 "Merc. Zephyr"   3291 20 3 3.5 17 2830 195 43 140 3.08 0 1
      38 "Olds Delta 88"  4890 18 4   4 20 3690 218 42 231 2.73 0 1
      51 "Pont. Phoenix"  4424 19 . 3.5 13 3420 203 43 231 3.08 0 1
      57 "Datsun 210"     4589 35 5   2  8 2020 165 32  85  3.7 1 1
      71 "VW Diesel"      5397 41 5   3 15 2040 155 35  90 3.78 1 1
      73 "VW Scirocco"    6850 25 4   2 16 1990 156 36  97 3.78 1 1
      end
      label values foreign origin
      label def origin 0 "Domestic", modify
      label def origin 1 "Foreign", modify
      Next, generate z values using r(mean), r(sd), and r(N) after summarize and check for outliers:
      Code:
      su weight, de
      ge zweight = (weight-r(mean))/(r(sd)/sqrt(r(N)))
      count if zweight >= 3 & zweight < .
      count if zweight <= 3
      And finally reporting the results counting outliers:
      Code:
      . count if zweight >= 3 & zweight < .
          2
      . count if zweight <= 3
          8
      Posting again.

      Comment


      • #4
        And an oops:
        Code:
        . count if zweight >= 3 & zweight < .
            2
        . count if zweight <= -3
            3

        Comment


        • #5
          Should have started by:
          Platform: Windows
          Version: 13.1
          ??Flavor: IC

          Comment

          Working...
          X