我有一个数据集,其中所有变量都已标记,另一个数据集根本没有。这两个数据集具有相同的变量集。如何在其他数据集中使用第一个数据集的变量标签(而不是值标签)?
答案 0 :(得分:1)
如果在具有变量标签的数据集在内存中时键入此循环
foreach v of var * {
di `" label var `v' "`: var label `v''" "'
}
您将获得一系列命令,可以复制并粘贴到do文件中以应用于其他数据集。几乎可以肯定有一个程序可以做到这一点,但是search label
想出了太多的发现让我想要通读以找到一个程序而不是写一个程序。
答案 1 :(得分:1)
这是一种可行的替代方法;请注意,如果两个文件中的变量不是同一类型。
. use `file2', clear
. describe
Contains data from /var/folders/xr/lm5ccr996k7dspxs35yqzyt80000gp/T//S_00996.000009
obs: 5
vars: 1 8 Jun 2016 21:21
size: 20
------------------------------------------------------------------------------------------------
storage display value
variable name type format label variable label
------------------------------------------------------------------------------------------------
x float %9.0g
------------------------------------------------------------------------------------------------
Sorted by:
. use `file1', clear
. describe
Contains data from /var/folders/xr/lm5ccr996k7dspxs35yqzyt80000gp/T//S_00996.000007
obs: 5
vars: 1 8 Jun 2016 21:22
size: 20
------------------------------------------------------------------------------------------------
storage display value
variable name type format label variable label
------------------------------------------------------------------------------------------------
x float %9.0g this is a label
------------------------------------------------------------------------------------------------
Sorted by:
. drop in 1/L
(5 observations deleted)
. append using `file2'
. describe
Contains data from /var/folders/xr/lm5ccr996k7dspxs35yqzyt80000gp/T//S_00996.000007
obs: 5
vars: 1 8 Jun 2016 21:22
size: 20
------------------------------------------------------------------------------------------------
storage display value
variable name type format label variable label
------------------------------------------------------------------------------------------------
x float %9.0g this is a label
------------------------------------------------------------------------------------------------
Sorted by:
Note: Dataset has changed since last saved.
.