Announcement

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

  • How to use "/" in Stata

    Hi everyone,

    I would like to know how to build a code that lets me display the following data:

    Individual's heights of those individuals whose weight is between 20 and 50 KG.

    I did try to type: list height if weight in (20/50).

    I know I could use the mathematical operators such as >= and <= but I am trying to understand how to use "/" properly in Stata.

    Thank you in advance.

    WEIGHT

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float weight
    19.2
    20.4
    20.5
    20.5
    21.9
    22.4
    24.4
    25.7
    25.9
    26.9
    27.5
    28.1
    28.2
      29
      29
    29.3
    29.4
      30
    30.1
    30.2
    30.5
    30.5
    30.9
      31
    31.6
    32.2
    32.2
    32.4
    32.7
    32.8
    32.8
    32.9
    33.1
    33.2
    33.4
    33.4
    33.6
    33.6
    33.7
    33.8
      34
      34
      34
    34.1
    34.3
    34.4
    34.5
    34.8
    34.9
    34.9
      35
      35
      35
    35.1
    35.1
    35.2
    35.3
    35.3
    35.4
    35.5
    35.5
    35.5
    35.5
    35.6
    35.6
    35.8
    35.8
      36
    36.1
    36.1
    36.3
    36.3
    36.4
    36.5
    36.5
    36.6
    36.6
    36.7
    36.9
      37
      37
      37
    37.1
    37.1
    37.1
    37.2
    37.2
    37.3
    37.3
    37.3
    37.3
    37.5
    37.5
    37.6
    37.6
    37.6
    37.7
    37.7
    37.7
    37.7
    end



    HEIGHT

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float height
    1.685
    1.538
     1.68
    1.702
    1.487
    1.638
      1.3
    1.505
    1.326
    1.485
      1.6
    1.595
    1.323
     1.67
    1.526
    1.405
    1.537
    1.514
     1.59
      1.5
    1.695
     1.44
    1.499
     1.64
    1.504
    1.542
    1.519
    1.567
    1.481
     1.54
    1.528
    1.637
    1.634
    1.501
      .79
     1.47
     1.46
    1.663
    1.454
        .
     1.56
     1.41
     1.49
    1.518
     1.46
    1.523
     1.52
    1.686
    1.534
     1.69
    1.475
    1.362
    1.589
    1.405
    1.739
    1.442
    1.457
    1.575
    1.472
    1.614
    1.396
    1.625
     1.58
    1.496
      1.5
    1.312
     1.52
     1.62
    1.505
    1.456
    1.482
    1.404
    1.484
     1.58
    1.608
    1.435
     1.71
     1.64
    1.533
     1.49
    1.535
     1.52
    1.593
      1.5
    1.465
    1.205
    1.528
     1.55
    1.502
    1.536
    1.589
     1.55
    1.524
    1.525
    1.477
    1.735
    1.582
     1.52
    1.474
        .
    end

  • #2
    list height if weight>=20 & weight<=50

    is what you need.

    list height in 20/50

    would list you the observations 20 to 50.

    Comment


    • #3
      Another way is

      Code:
      ... if inrange(weight, 20, 50)
      Best
      Daniel

      Comment


      • #4
        Originally posted by Joro Kolev View Post
        list height if weight>=20 & weight<=50

        is what you need.

        list height in 20/50

        would list you the observations 20 to 50.
        If I may add this. list height if weight >= 20 & weight <= 50 will list all observations whose weights are in [20, 50]
        however if you need the list of all observations whose weights are in (20, 50) as you stated in your question,
        then you will have to use list height if weight > 20 & weight < 50

        Comment


        • #5
          Thank you all!

          Comment

          Working...
          X