Hi, this is my first post in the forum, I hope I will do this correctly. I am using Stata 15.1
I have som regression results and graphs that I am pasting to Excel using putexcel.
The data will be put into the spreadsheet on different columns, and I am using local macros to store the column numbers. The number of columns in the spreadsheet is around 100. I was wondering if it possible to assign names to local macros using another macro? This is what I am doing now, and it is generating a lot of code and a lot of lines:
local col = 1
excelcol `col'
local c1 = r(column)
local col = `col' + 1
excelcol `col'
local c2 = r(column)
local col = `col' + 2
excelcol `col'
local c3 = r(column)
It would shorten things up if I could do something like this:
forval i=1/100 {
local col = "ì'"
excelcol col
local c"`i'" = col /* creating macros named c1, c2....c100 */
}
But I get all sorts of messages about unrecognized namem regarding on how I put the quotation marks in the statement "local c"`i'" ="
Is this possible at all?
Thank you all for a great forum!
I have som regression results and graphs that I am pasting to Excel using putexcel.
The data will be put into the spreadsheet on different columns, and I am using local macros to store the column numbers. The number of columns in the spreadsheet is around 100. I was wondering if it possible to assign names to local macros using another macro? This is what I am doing now, and it is generating a lot of code and a lot of lines:
local col = 1
excelcol `col'
local c1 = r(column)
local col = `col' + 1
excelcol `col'
local c2 = r(column)
local col = `col' + 2
excelcol `col'
local c3 = r(column)
It would shorten things up if I could do something like this:
forval i=1/100 {
local col = "ì'"
excelcol col
local c"`i'" = col /* creating macros named c1, c2....c100 */
}
But I get all sorts of messages about unrecognized namem regarding on how I put the quotation marks in the statement "local c"`i'" ="
Is this possible at all?
Thank you all for a great forum!
Comment