Announcement

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

  • Dataset become blank when using any command

    Hi guys,

    I am using StataNow/SE 18.5. I imported excel files in Stata and converted them to state files (.dta). And continue my work by restarting Stata and opening those .dta files, but whenever I type any command, the dataset become blank and returns false or no results.

    for example, I type "bys CompanyName (date):gen ri = (closing/closing[_n-1])", then returned xxx,xxx missing values generated (all values are missing and my dataset become an empty dataset). However, this problem does not occur in my other files. May I know if this is a bug or if I can do anything to resolve it?

    Thanks a lot.

  • #2
    Please see the FAQ to see how to ask a question. There's likely a reason for this, but we need to see exactly what you did in order for us to best help you. So please, read the FAQ, and then return to this post so we can get to the bottom of things.

    Welcome to Statalist, Kim Szeto.

    Comment


    • #3
      I know for a fact your example command must produce missing values because the value prior to the first observation in each group doesn’t exist and Stata treats this as a missing value. Any mathematical operation done on missing values from then on are also missing. To rectify that, add the if condition to the end your statement

      Code:
      if _n>1
      This tells Stata to start calculation from the second observation.

      If, as you typed, your entire dataset becomes missing, then that’s a different matter entirely. You need to follow Jared’s advice to either post a reproducible example or perhaps contact Technical Support.

      Comment

      Working...
      X