reshape 那些事儿

长变宽
reshape wide pcgdp,i(city) j(year)

i(varlist) 只是充当在wide形式下唯一的识别变量(组)而已,并不要求必须是序号(数字型)。

Basic syntax

        Convert data from wide form to long form
            reshape long stubnames, i(varlist) [options]

        Convert data from long form to wide form
            reshape wide stubnames, i(varlist) [options]
  options                    Description
       ----------------------------------------------------------------------------------------------------------------------------------------
       * i(varlist)                 use varlist as the ID variables
         j(varname [values])        long->wide: varname, existing variable
                                    wide->long: varname, new variable
                                    optionally specify values to subset varname
         string                     varname is a string variable (default is numeric)
       ----------------------------------------------------------------------------------------------------------------------------------------
        * i(varlist) is required.

 Advanced syntax:
        reshape i varlist
        reshape j varname [values] [, string]
        reshape xij fvarnames [, atwl(chars)]
        reshape xi [varlist]
        reshape [query]
        reshape clear

Options
\color{red}{string} specifies that j() may contain string values.
\color{red}{atwl(chars)}, available only with the advanced syntax and not shown in the dialog box, specifies that plain ASCII chars be substituted for the @ character when converting the data from wide to long form.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容