Announcement

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

  • How to highlight a row in data editor's stata?

    i have hundred thousand observations, and i need to highlight the row that consist the minimal or maximal value of my variables. Can you help me and show me the command? Because it's really tiring if i check it one by one manually. Thank you

  • #2
    The data editor is not a spreadsheet and it does not include highlighting as a feature. If you select an observation by clicking on its row number, you will see it temporarily highlighted, but that relies on your figuring out first which observation contains the minimal or maximal value. Also, you can only select a single observation or a block of consecutive observations: you can't select two observations that are not adjacent. I'm pretty sure there is no way to get the editor to automatically select those observations. What you can do, if it's helpful, is open the data editor with only the observations containing the minimal or maximum values.

    The way your question is posed it seems to imply that in your data there is one observation in which every variable is minimal and another where every variable is maximal. While that's possible, it's very unusual and I suspect it isn't what you mean. It is more likely that every variable achieves its minimum or maximum value in different observations. I don't know if you want to do this separately for each variable, or have a look at one screen showing those observations for which any variable achieves its minimum or maximum observation. I'm going to assume you want to do this one variable at a time. So if you want to do this for variable v:

    Code:
    summ v
    edit if inlist(v, r(min), r(max))
    will open the editor containing only observations where v has the minimum or maximum value.

    By the way, I don't know what you plan to do once the editor is open. If all you want is to look at the data, it is safer to use -browse- instead of -edit- to avoid the possibility you will inadvertently overwrite some of the data. If you are planning to actually make changes to the data, then -browse- won't allow that, but given that you need an audit trail for anything you do with your data, you should be sure that you have a log on to record any changes you make in the editor.

    Comment


    • #3
      extremes from SSC may help.

      Comment


      • #4
        Hello!

        Clyde's comment saved my day. I have nearly 14,000 observations from a decision-making experiment and needed to check whether some observations have a given variable with values below a given number, let's say below or equal to 50. I'm using Stata 15.1. Assuming the variable of interest is called decision, the code I used was the following:

        Code:
        browse if inrange(decision, 0, 50)
        When looking for information about inlist in the reference manual, immediately below I saw an entry for inrange. The code above allowed me to extract the observations with decisions below 50 (the 0 is simply an artificial lower bound that allowed me to do the trick).

        Thanks,
        JA

        Comment

        Working...
        X