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
New on SSC - complexity : computes Complexity Indexes similar to ECI/PCIDear Statalisters, This post to announce that I've released complexity - a package to compute compl…
Generating a wave (time) variable in a panel data setI want to generate a variable 'wave' to identify each wave in the dataset. I have the responding per…
xtline and standard deviationHello everyone, I need to draw a lineplot for paneldata. I used the following command: collapse (m…
create a new variable from weighted variables?Hello everyone, I'm now stuck into this one: I have a data-set and a (sample) weight variable. Due …
Bilateral exchange rate data with and without make changes in overall results.Dear Statalist, I am using a bilateral exchange rate variable in the gravity model. However, when I…
Subscribe to:
Post Comments (Atom)
0 Response to How to rename around 200 rows of a matrix simultaneously or in iteration
Post a Comment