Hello everyone,
Using STATA16, I have a dataset with 20 variables dx1 to dx20. I want to keep only observations with T40xxxx, T41xxxx, T42xxxx, and T43xxxx. When I use "keep" command for the first variable (dx1) I missed the other variables.
keep if inlist(substr(dx1, 1, 3), "T40", "T41", "T42", "T43")
Another way that I tried is to generate new var that helped me to gen a new var contains observation with T40xxxx, T41xxxx, T42xxxx, and T43xxxx.
gen DX1= dx1 if inlist(substr(dx1, 1, 3), "T40", "T41", "T42", "T43")
This way takes a lot of time. I am wondering how I can keep only observations in each variable (dx1 to dx20) that contain T40xxxx, T41xxxx, T42xxxx, and T43xxxx. Is there any other way for doing this, for example, writing a loop for :
gen DX1= dx1 if inlist(substr(dx1, 1, 3), "T40", "T41", "T42", "T43")
Thank you in advance for your advice.
Best
Array
Related Posts with select specific observation among several variables
Difference between poisson model with exposure and modelling rates implicitly?Dear Statalists, I trying to understand the difference between using an exposure in a poisson model…
Calculating annual visit using visit dateHi there! I am a rather novice Stata user doing an MPH. I am using Stata 15 IC on Windows 10; my da…
Running regression based on size each yearDear Experts, I have an unbalanced panel data of all NYSE, AMEX and NASDAQ firms from 1998 to 2018.…
Robust Estimation - VAR modelHello all, How do I perform robust estimation in VAR to correct for presence of any heteroskedastic…
generate varialbe on the conditionHi , I want to generate the variable only up the condition of another variable here, local 38"phon…
Subscribe to:
Post Comments (Atom)
0 Response to select specific observation among several variables
Post a Comment