怎么查找变量中的某个值
Sorry, should be this:
gen a=cty1+cty2
gen b=abs(cty1-cty2)
egen group=group(a b)
save temp, replace
collapse (sum) export (min) id (max) id, by(group)
Most likely, your “id” is a string variable, try this first:
encode id, gen (id_n)
then change the last command as follows:
collapse (sum) export (min) id_min=id_n (max) id_max=id_n, by (group)
The following is a better one to convert the string “id” variable:
destring id, gen (id_n1)
then change the last command as follows:
collapse (sum) export (min) id_min=id_n1 (max) id_max=id_n1, by(group)
刚才有试了一下。出现了r(111) error . . . . . . . . . . . . . . . . . . . . . . . . Return code 111
__________ not found;
no variables defined;
The variable does not exist. You may have mistyped the
variable’s name.
variables out of order;
You specified a varlist containing varname1-varname2, yet
varname1 occurs after varname2. Reverse the order of the
variables if you did not make some other typographical error.
Remember, varname1-varname2 is taken by Stata to mean varname1,
varname2, and all the variables in dataset order in between.
Type describe to see the order of the variables in your dataset.
__________ not found in using data;
You specified a varlist with merge, yet the variables on which
you wish to merge are not found in the using dataset, so the
merge is not possible.
__________ ambiguous abbreviation;
You typed an ambiguous abbreviation for a variable in your data.
The abbreviation could refer to more than one variable. Use a
nonambiguous abbreviation or, if you intend all the variables
implied by the ambiguous abbreviation, append a `*’ to the end
of the abbreviation.
转载请注明:数据分析 » 怎么查找变量中的某个值_stata培训