Hi All,

I currently have data which resembles the following:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(x1 x2 x3 x4 y1 y2 y3 y4)
1 2 3 4 5 6 7 8
end
Here, I have 8 variables- 4 corresponding to x and 4 to y, with their respective indices. I wish to calculate the changes from 1 to 2,3 and 4 for both x and y, and then export the percentage changes only to excel in the same file.

Specifically, this is what I had in mind:

Code:
preserve
drop y*
foreach i in x2 x3 x4 {
g change`i'=(`i'-x1)/x1
}
drop x*
...
restore
drop x*
foreach i in y2 y3 y4 {
g change`i'=(`i'-y1)/y1
}
drop y*

The ... represent my ignorace of how to export just the changes variables (changex2, changex3, changex4) to excel in say row 1, and the do the same operation for the y variables. Essentially, the final excel document I would want would be two rows, with each row corresponding to the different changes to either x or y, with ideally some way of telling which is which.

I looked at the -putxcel- and -export- class of commands, but remain unsure of how to append data thus.


Many thanks for your consideration,
CS