Announcement

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

  • Descriptive statistics if command error r(198)

    Hi everyone,

    I am trying to create a descriptive statistics table of my data but only for the cases in which all the variables are observed in order to have the same number of observations for all my variables.

    When I run the following command:

    [sum country1 cid year fdiunctad1 fdiwdi1 wgi1 icrg csp acled ucdpdeaths ucdpconflicts edb91 edb51 gdpgrowth1 gdppercapita1 trade1 inflation1 exchangerate1 telephone1 cellphone1 education1 if country1!=. & cid!=. & year!=. fdiunctad1!=. & fdiwdi1!=. & wgi1!=. icrg!=. & csp!=. & acled!=. ucdpdeaths!=. & ucdpconflicts!=. & edb91!=. edb51!=. & gdpgrowth1!=. & gdppercapita1!=. trade1!=. & inflation1!=. & exchangerate1!=. telephone1!=. & cellphone1!=. & education1!=.]

    Stata tells me that whichever variable after year is invalid and it gives me the error r(198).

    Can you see any mistake in the formula or would you know what is the reason of it?

    Thank you very much in advance.

    Regards,
    Siham

  • #2
    Code:
     if country1!=. & cid!=. & year!=. fdiunctad1!=. & fdiwdi1!=. & wgi1!=. icrg!=. & csp!=. & acled!=. ucdpdeaths!=. & ucdpconflicts!=. & edb91!=. edb51!=. & gdpgrowth1!=. & gdppercapita1!=. trade1!=. & inflation1!=. & exchangerate1!=. telephone1!=. & cellphone1!=. & education1!=
    There is a missing & before fdiunctad and one before icrg and several other missing &s later in the command.

    Note that if a b c d e are all numeric then

    Code:
    regress a b c d e
    allows if e(sample) to be used afterwards to identify observations with non-missing values on all those variables, as the other observations are excluded from the estimation sample.

    More at http://www.stata-journal.com/article...article=dm0030
    Last edited by Nick Cox; 20 Nov 2019, 12:27.

    Comment


    • #3
      Can you see any mistake in the formula or would you know what is the reason of it?
      Yes. You need another ampersand (&) between year!=. and fdiunctad1!=.

      Added: Crossed with #2 which gives essentially the same response.

      While we're at it, you can save yourself a lot of typing by revising the code as follows:

      Code:
      local myvars 
      country1 cid year fdiunctad1 fdiwdi1 wgi1 icrg csp acled ucdpdeaths ucdpconflicts /// edb91 edb51 gdpgrowth1 gdppercapita1 trade1 inflation1 exchangerate1 telephone1 /// cellphone1 education1 egen mcount = rowmiss(`myvars') summ `myvars' if mcount == 0
      Last edited by Clyde Schechter; 20 Nov 2019, 12:25.

      Comment


      • #4
        Thank you Nick!

        Last edited by Siham Hari; 20 Nov 2019, 12:39.

        Comment


        • #5
          very helpful, thank you Clyde!!

          Comment

          Working...
          X