Stata Technical Bulletin
STB-20
I wrote mergedct.ado to avoid these steps. mergedct is just like Stata’s merge command except mergedct combines
the current data set with a raw or dictionary file rather than a .dta-file. The syntax for mergedct is
mergedct VyrrSsst∖ using filename [, automatic byvariable(#)
nolabel u2(aien2me2^) vlist (yrrlisf) ]
Options
mergedct combines the options of infile and merge. The automatic, byvariable(#), and u2(filrname2) options
have the same effect as the infile options automatic, byvariable(#), and usingnrien2me2), respectively. The nolabel
option has the same effect as the merge command’s nolabel option.
The vlist Varl-Isst) option is new. It is used to identify the variables when merging raw (non-dictionary) data files. The
command
. mergedct using rawdata, vlist(x y z)
indicates that the raw data can be read using the following infile command:
. infile x y z using rawdata
Examples
Here’s an example of merging a dictionary file. Note that mergedct does not require the disk data set to be sorted in
advance.
. use dta, clear
. describe
Contains data from dta.dta
Obs: 10 (max= 32766)
Vars: 2 (max= 99)
Width: 6 (max= 200)
1. order int %8.Og
2. x float %9.0g
Sorted by: order
. list
order |
x | |
1. |
1 |
1.605509 |
2. |
2 |
-1.363875 |
3. |
3 |
1.255479 |
4. |
4 |
.6902485 |
5. |
5 |
.7910749 |
6. |
6 |
-1.067126 |
7. |
7 |
1.471047 |
8. |
8 |
-1.971935 |
9. |
9 |
1.805707 |
10. |
10 |
-.5496167 |
• type |
indict1 |
. det |
dictionary { | ||
int |
order |
float y
10 .7764114
1 -1.849471
2 .4429037
3 2.122414
4 .3309246
5 -.6871347
6 1.272875
7 -.4236486
8 -1.741924
9 -.4869484
. mergedct order using indict1
. list