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
Panel Structural VARHello all, I am working on finding the us monetary policy impact on a bunch of countries and for thi…
Interpreting coefficients in log-linear model when independent var is percentIf I run a model where the dependent variable is log sales price of a home and the independent varia…
Calculate total grants company_id year grant co_001 2003 1 co_001 2004 0 co_001 2005 1 co_001 2005 1 co_002 20…
Calculate total grants company_id year grant co_001 2003 1 co_001 2004 0 co_001 2005 1 co_001 2005 1 co_002 20…
GMM methodGoodnight all, I have some problems regarding the GMM method for a sample (panel study) of 14 countr…
Subscribe to:
Post Comments (Atom)
0 Response to select specific observation among several variables
Post a Comment