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
Finding the earliest date within two boundariesI have three date variables corresponding to the beginning of three surveys for different individual…
Propensity score matchingHi, Our outcome variable is birthweight and independent variables are antenatal care, education, age…
egen corr() with weightsDear Statalisters, I have panel data and want to compute a time series of cross-sectional correlati…
The GMM modelHello everyone, I have a question that I need to be sure about Can we use the GMM model when the de…
icio save is not workingI am doing gvc analysis. I made a do file containing icio command. Other command is working well, bu…
Subscribe to:
Post Comments (Atom)
0 Response to How to rename around 200 rows of a matrix simultaneously or in iteration
Post a Comment