Announcement

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

  • from SPSS to Stata syntax

    Hello,

    After rewriting my SPSS-syntax to Stata-syntax and working with Stata for a while, I have to redo an analysis that was originally programmed in SPSS. The SPSS-syntax is:

    compute i_vo=mean(vo)
    compute ii_vo=(i_vo*n-vo)/(n-1)

    For the first command I now use in STATA:
    egen i_vo = mean(vo)

    But how can I rewrite the second SPSS-command in STATA?

    Thanks for your help!
    Daniƫlle

  • #2
    Hello Danielle,

    Welcome to the Stata Forum.

    I kindly ask you to present commands under CODE delimiters, as recommended in the FAQ.

    For example, you may try this code:

    Code:
    . gen ii_vo = (i_vo*n-vo)/(n-1)
    Please prefer to refer to "Stata" (only the first letter is capital).

    Best,

    Marcos
    Best regards,

    Marcos

    Comment


    • #3
      I assume n stands for sample size? If so, I might do

      Code:
      sum vo
      gen i_vo = r(mean)
      gen ii_vo=(i_vo*r(N) - vo)/(r(N)-1)
      Or, if you don't really need i_vo,

      Code:
      sum vo
      gen ii_vo=(r(mean)*r(N)-vo)/(r(N)-1)
      Or, for that matter,

      Code:
      sum vo
      gen ii_vo=(r(sum)-vo)/(r(N)-1)
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      StataNow Version: 19.5 MP (2 processor)

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

      Comment


      • #4
        Indeed, n stands for sample size. Thanks a lot!

        Comment

        Working...
        X