stata split
时间: 2023-10-28 10:40:47 浏览: 135
stata
5星 · 资源好评率100%
Stata split command is used to divide a string variable into multiple separate variables based on a specified delimiter. It is useful when a single string variable contains multiple pieces of information that need to be separated into different variables for analysis or formatting purposes.
Syntax:
split varname, gen(newvarlist) [p(string)] [destring] [delimiter(string)] [generate] [parse(string)] [complete] [missing(string)] [uppercase] [lowercase] [propercase] [replace] [noempty] [force] [genprefix(string)] [drop] [keep] [sort]
Explanation:
- varname: The name of the string variable to be split.
- gen(newvarlist): The new variable(s) created from the split, separated by a space.
- p(string): Specifies a prefix to be applied to the variables created by split.
- destring: Automatically converts the new variables to numeric format if possible.
- delimiter(string): Specifies the delimiter to use to split the string variable. The default is a space.
- generate: Creates new variables for each split regardless of whether they are specified in newvarlist.
- parse(string): Specifies a regular expression to use for parsing the string variable.
- complete: Stata will stop execution if there are any missing values in the original variable.
- missing(string): Specifies a string to represent missing values.
- uppercase: Converts all new variables to uppercase.
- lowercase: Converts all new variables to lowercase.
- propercase: Converts all new variables to proper case.
- replace: Replaces any existing variables with the same name.
- noempty: Removes any empty variables created by the split.
- force: Forces the creation of new variables even if they already exist.
- genprefix(string): Specifies a prefix to be applied to all new variables created by split.
- drop: Drops the original string variable after the split.
- keep: Keeps the original string variable after the split.
- sort: Sorts the new variables alphabetically.
阅读全文