1、encode varname, gen (newvarname),重新⽣成⼀个新的变量,内容与字符型的相同。2、 Convert string variables to numeric variables:destring [varlist] , {generate(newvarlist)|replace} [destring_options]字符转数值 Convert numeric variables to string variables:tostring varlist , {generate(new...
Convert string to numeric Convert numeric to string Sort and compare Unicode strings based on locale Regular expression pattern matching Regular expression pattern replacement Regular expression pattern subexpressions Convert string to valid Stata name Wildcard pattern matching Convert strings to/from Unicode...
至于你用destring为什么出现问题,你的错误提示说明,你那个变量里面存在非数字的字符。你应该仔细检查一下,变量里存在什么字符。如果你确认这个变量就应该是数字,可以直接转换的话。那么,可以在destring后面加上force参数 destring var, replace force force参数的作用是“convert nonnumeric strings to missing values” ==...
destring String,gen(Str2Num)tostring Number,gen(Num2Str) 初学者总是容易将destring和encode混淆,其实两者的用途是有区别的: destring: Convert string variables to numeric variables and vice versa. encode: Encode string into numeric and vice versa. encode主要用于将数据进行编码、分组,将连续性变量转换成分组...
force参数的作用是“convert nonnumeric strings to missing values” === destring var2,force replace 这个命令不就行了 ? 要是直接用这个,对于是负数的内容会直接missing === <hr/>// 如何将stata中的字符型数据转为数值型 * Example generated by -dataex-. To install: ssc install dataex clear...
destring : convert string variables to numeric foreach : loop over elements of a list, performing a block of code forvalues : loop over a numlist, performing a block of code local : define or modify a local macro (scalar variable)
To convert the above date variable to an elapsed date format, you must first convert the numeric variable to a string and then use thedate()function. For example, . tostring datevar, replace format(%20.0f)datevar was long now str8. replace datevar = "0" + datevar if length(datevar)...
String variables How can I quickly convert many string variables to numeric variables? How can I turn a string variable containing dates into a date variable Stata can recognize? How can I extract a portion of a string variable using regular expressions?
Stata数据管理——数据管理命令简介说明书 Title stata.com data management—Introduction to data management commands Description Reference Also see Description This manual,called[D],documents Stata’s data management features.See Mitchell(2010)for additional information and examples on data management in Stata...
Stata日期和时间处理指南说明书 in Stata Gabriela Ortiz Applied Econometrician StataCorp LLC 1