One of the common ways of getting things done in Stata is to add observations to the end of the dataset, then modify them in some way. The -expand- command makes this easy, by adding replicates of the observations in memory on to the end, after which you can modify them. You will likely want to save the current number of observations to a local so you know which are the new copies: - local originalN = _N -
Want to duplicate your dataset?
-expand 2-
Want to triplicate your dataset?
-expand 3-
Want to duplicate only the observations from year 1999?
-expand 2 if year==1999-
If you want to create blank rows at the end of a dataset, use -set obs- instead:
local numobs = _N + 1
set obs `numobs'
replace x = 10 in l
Monday, January 17, 2011
Subscribe to:
Post Comments (Atom)
expand
ReplyDeleteThanks for the good article, has been very useful for me. Thanks for sharing.
ReplyDeleteBuy Pre Written Essays
Online Writing Services
Accounts Software For Small Business