I have a dataset and want to keep a number of variables - Soundex started with a letter, for example, those which started with "H" like H0028. The variable's name is "contractid" and I want to keep only those started with H or R or E
I used the following command but it doesn't work
keep if substr(string(contractid), 1,5) == "H" | substr(string(contractid), 1, 5) =="R" | . substr(string(contractid), 1,5 )=="E"
I would greatly appreciate your help
Related Posts with keeping soundex started with a specific letter
Create categorical variables from string variableHello! I have a problem: I have a dataset which include Chinese cities, however, they are stored in…
Generating a new variable based on inequality between two other variables for certain valuesHi guys, this is actually the first time I am posting something in this forum. I am currently worki…
Fixed effect model and Endogeneity problemsHello! This is my first post on Statalist, and I am very grateful for any comments and suggestions. …
A question on using macro variableI am running several models and only wanted to export selected regression coefficients to excel. So …
Coefplot for marginal effectsHi all, I'm trying to create a plot, similar to Stata's `coefplot`, but for marginal effects. I hav…
Subscribe to:
Post Comments (Atom)
0 Response to keeping soundex started with a specific letter
Post a Comment