Announcement

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

  • do we have simpler syntax to realize this goal?

    Code:
    if lnEmployee1Y ~=. & lnCash1Y~=. & lnTtlAsset1Y~=. & stdRevenue1Y~=. & stdNetProfit1Y~=. & lnRDExp1Y~=.
    Thanks so much!

  • #2
    Code:
    if !missing(lnEmployee1Y, lnCash1Y, lnTtlAsset1Y, stdRevenue1Y, stdNetProfit1Y, lnRDExp1Y)
    will work provided your data set does not use any missing values other than the system missing (.). If you do have other missing values in the data, and you do not want to proceed if one of those values is taken on by one of the variables, then the following code is more specific to just system missing:

    Code:
    if !inlist(., lnEmployee1Y, lnCash1Y, lnTtlAsset1Y, stdRevenue1Y, stdNetProfit1Y, lnRDExp1Y)

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      Code:
      if !missing(lnEmployee1Y, lnCash1Y, lnTtlAsset1Y, stdRevenue1Y, stdNetProfit1Y, lnRDExp1Y)
      will work provided your data set does not use any missing values other than the system missing (.). If you do have other missing values in the data, and you do not want to proceed if one of those values is taken on by one of the variables, then the following code is more specific to just system missing:

      Code:
      if !inlist(., lnEmployee1Y, lnCash1Y, lnTtlAsset1Y, stdRevenue1Y, stdNetProfit1Y, lnRDExp1Y)
      This is exactly what I want! Thanks so much!

      Comment


      • #4
        I also like

        Code:
        reg y x1 x2 x3 x4
        gen mysample = e(sample)
        Subsequent commands that want to restrict the sample can just add if mysample

        It is especially handy if you are going to further restrict the sample, e.g. only analyze women.

        I mostly like the simplicity of the command. The other proposed solutions work but are more complicated and, I suspect, more prone to syntax mistakes. The reg command itself doesn't have to be something you are interested in, it just has to have all the variables you want.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        Stata Version: 17.0 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://www3.nd.edu/~rwilliam

        Comment


        • #5
          Originally posted by Richard Williams View Post
          I also like

          Code:
          reg y x1 x2 x3 x4
          gen mysample = e(sample)
          Subsequent commands that want to restrict the sample can just add if mysample

          It is especially handy if you are going to further restrict the sample, e.g. only analyze women.

          I mostly like the simplicity of the command. The other proposed solutions work but are more complicated and, I suspect, more prone to syntax mistakes. The reg command itself doesn't have to be something you are interested in, it just has to have all the variables you want.
          Thank you so much! This is another smart way!

          Comment

          Working...
          X