Massimiliano emailed me off-list to let me know that the solution Nick and I proposed for his problem will not work because his data is not in electronic format. Massimiliano can still avoid Excel.
It sounds like the -tsappend- command, which can add one year to a panel dataset, might be helpful. Massimilaino can then use a loop and -replace- to fill in the new data. An example (unfortunately using monthly data) follows:
********Begin example***********
* set up
webuse tsappend2, clear
* Data goes through Jan. 2000 and has three cross-sectional units
xtdescribe
describe
*Add observation for Feb. 2000
tsappend, last(2000m2) tsfmt(tm)
*Create local lists with new updated values for each cross-sectional unit
local eupdates ".1 .2 .3"
local xupdates ".05 .1 .15"
local yupdates "15 20 25"
foreach var in e x y {
forval i = 1/3 {
*Replace variables with the appropriate data for Feb. 2000
local `var'update: word `i' of ``var'updates'
replace `var' = ``var'update' if t2==tm(2000m2) & id==`i'
}
}
list if t2==tm(2000m2)
********************* End Example*****************
Hope this helps.
Howie
-----Original Message-----
From: Volpi, Massimiliano [mailto:[email protected]]
Sent: Wednesday, May 13, 2009 10:07 AM
To: Howard Lempel
Subject: RE: RE: data management updating a panel dataset
Dear Howard,
thanks for answering my question in statalist.
I will have to edit the data in Excel, simply because they are not available as electronic file, but only on paper.
The reason I tried to avoid this, is that the last time I copied data by hand I had a few problems: I left empty spaces after the identifying names, but then Stata obviously treated the strings as different. Will have to pay attention to this.
Anyway I wanted to check I was not overlooking anything and your and Nick's answer reassured me I am not.
Thanks a lot.
Best Regards
Massimiliano
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Volpi, Massimiliano
Sent: Tuesday, May 12, 2009 5:47 PM
To: [email protected]
Subject: st: data management updating a panel dataset
Dear Statalisters,
I would like to update a panel dataset in Stata, for which a further year of observations has become available.
I would like to tell Stata to generate new observations and then edit them within Stata.
This would seem to me as a better option than listing the identifying variables, copying them as table, editing them in Excel and then appending the new to the old data base, which is the only alternative I see.
Any suggestion on how to do it? Or is there a reason for not doing so?
I am using Stata10.1
Many thanks
Massimiliano
--
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/