Announcement

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

  • Calculating averages over a time-series

    Hello,

    I am looking for a function to calculate the average unemployment rate (mean) over two sets of years (2007-2011) and (2012-2020) for various regions defined by the variable 'regionid'. For the years I have produced a dummy variable 'post' where post=0 if year <= 2011 and post=1 if year > 2011.

    I have tried the following functions but I am having difficulty in combining them into one function which incorporates both post and regionid.
    tabstat ur, stat(mean) by(regionid)
    tabstat ur, stat(mean) by(post)

    I am looking to create a table like this using STATA.

    Could someone please guide me in finding the right command.

    Click image for larger version

Name:	Screenshot 2022-04-11 at 02.05.51.png
Views:	1
Size:	35.4 KB
ID:	1658979

    Thank you.

  • #2
    Code:
    version 16: table regionid post, c(mean ur)
    Note: code assumes you are using version 17, which is the current version. If you are using an earlier version, you are supposed to say that in your post. If, in fact, you are using an earlier version than 17, then omit the -version 16:- prefix from the command.

    Comment


    • #3
      Yes, I am using version 17. This works perfectly, thank you so much for your help.

      Comment

      Working...
      X