In other problems this detail could be crucial. moss finds occurrences of substrings matching a pattern in a given string variable. If that were ever false, and you only wanted the first occurrence to be replaced, then the advice is to do something like subinstr(myvar, "CC", "18", 1) where the last argument 1 stipulates the (maximum) number of replacements to be made. previous thread How do I find and replace a part of a string variable in Stata?ĮDIT The implication of the question appears to be that the strings to be replaced occur just once. You will learn how to manipulate and create databases, manage variables and information, construct datasets from several data sources, perform simple quantitative data analysis, reproduce your work for further analysis using do-files and solve common quantitative problems found in real world scenarios in data. replace myvar = subinstr(myvar, "PC", "35". In this introductory course, you will learn how to use Stata for data analysis. You want to rename, not replace (my guess): clear set obs 1 gen a1va0100 1 gen a2va0100 2 gen a3va0100 3 describe forvalues i 100(100)300. replace myvar = subinstr(myvar, "VC", "75". Stata extracts a substring from a string based on its position with the substr() function. replace myvar = subinstr(myvar, "CC", "18". A DataFrame in pandas is analogous to a Stata data set a. Documented in the same place: start at help functions. The substr() function (not substring() not a command) is not as helpful here as its sibling, subinstr().
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |