Hi, I'm very new to Stata and I've searched and tried answers for this question for three hours. I'm using Stata16. I have covid related data (daily cumulative/new cases/deaths data) of each country and I would like to set row's name to be according country's name. To examine on each country's data, I firstly split the data set to 195 dta files:
levelsof location, local(level1)
foreach x of local level1 {
preserve
keep if location=="`x'"
save file`x',replace
restore
}
Then I repeat a regression on each country's data using foreach, resulting in a matrix of R^2
Array
I've renamed columns. However, I don't know how to rename around 200 rows easily.
I have two ideas. I firstly tried to use levelsof to extract location names from original covid related dataset and set it to be the rows' names:
frame owid: levelsof location, local(rownames)
matrix rownames R2 = `rownames'
However, it seems that the dataset is another frame, the list of locations cannot be row names? The row names were not changed.
Then, I tried to rename each row in iteration:
local myfilelist: dir . files "*.dta"
local rownames
foreach filename of local myfilelist {
use `filename', clear
local rownames `rownames' `filename'
}
matrix rownames R2 = `rownames'
But I got error message: fileafghanistan: operator invalid
I'm sorry if I am not clear in questioning. I previously used other softwares and Stata is quite new for me. I will appreciate if you can give some advice on codes.
Thank you for your time and help!
Related Posts with How to rename around 200 rows of a matrix simultaneously or in iteration
ByHist - to create a histogramI would like to plot a histogram using weights. Just like Ariels' paper here. Graphical displays for…
export multiple regression results.Hello to all, I'm creating this topic because I haven't found my answer on it. I am currently stuc…
Obtaining time series graphsHey guys, sorry if this is long, but I'm entirely new to stata. I also apologise if I don't use the …
parentheses do not balanceHello, I am trying to do a graph with confidence intervals. I got the following code: twoway (rcap …
What is the meaning of p-value for trends?Hello, I am working on an assignment that asks for the interpretation of a ptrend value in a regres…
Subscribe to:
Post Comments (Atom)
0 Response to How to rename around 200 rows of a matrix simultaneously or in iteration
Post a Comment