Announcement

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

  • Creating variable with stored scalars

    Dear All,
    If feasible, how can I create a variable using a number of stored scalars? Optionally, how do I export the scalars to MS word?

    Thanks,
    Dapel

  • #2
    Code:
    gen whatever = foo
    gen whatever2 = foo in 1
    replace whatever2 = bar in 2

    will work if foo is a scalar and there is no such variable name; with similar comments for bar. If necessary, use scalar() to disambiguate, i.e. scalar(foo) makes clear that you want the scalar.

    Comment


    • #3
      Solved. Thanks. One more: I run a number of regressions from a single dataset, e.g.
      Code:
      reg y x1 x2 if year==2004
      reg y x1 x2 if year==2010
      using the same set of variables but different years-sort of a stacked dataset. After the first regression, I created a scalar using the constant
      Code:
       sca constant_2004=(_b[cons]^(1/7))/(1-_b[_cons])
      . I run the second regression and also the
      Code:
      sca constant_2010=(_b[cons]^(1/7))/(1-_b[_cons]).
      After these, I sca list There was result for
      constant_2004
      but none for
      constant_2010
      . Both constants are positive. Please help if you understand my explanation.
      Last edited by Zuhumnan Dapel; 23 Feb 2015, 03:11.

      Comment


      • #4
        Here is an idea, but I doubt that it's really the solution.

        I notice that the command you posted for constant_2010 ends in a period. If that's what you typed in your work, it's a syntax error, and an error message results when I try to run something similar. You didn't see an error message, of course. However, if I place the command into a do-file and run the do-file with the capture prefix, the error message is suppressed. So if by chance that's what you did - create the scalars in a do-file that was run with the capture prefix - that could explain the lack of a result for constant_2010.

        Again, I doubt that that's the case, but thought I should mention the possibility. It's so easy to overlook the period at the end.

        Comment

        Working...
        X