Consider the following example dataset:
member like deposit age
1 1 9997 22
2 2 892 23
1 1 267 34
1 9 1728 54
3 1 9999 22
1 2 2123 34
9 2 445 13
1 1 928 22
1 1 276 34
2 1 . 23
2 1 3728 45
3 2 3652 34
. 1 451 35
. 1 231 67
2 9 234 17
3 2 3872 37
1 1 102 45
1 1 676 56
3 . . 35
2 . 9999 67
All variables are numeric. The variable label and value labels are:
label var member "Are you a member of the club?"
label var like "Do you like it?"
label var deposit "How much in your account?"
label var age "Age"
label values member memberl, nofix
label define memberl 1 "member" 2 "nonmember" 3 "waiting" 9 "Refuse to answer"
label values like like, nofix
label define like 1 "like" 2 "don't like" 9 "don't know"
label value deposit dmoney, nofix
label define dmoney 9997 "N/A" 9999 "don't know"
The age variable has no system-missing values and no use-defined missing values. And there is a note (survey question number) for each variable:
notes member: QT35
notes like: QR22
notes deposit: Q6
notes age: info3
My goal is to export those information into a single data set (or a Excel table) as follows.
In a data set form:
http://i1279.photobucket.com/albums/y531/tpbest33/wanted_output_dataform_zps52953ecf.jpg
Or, in an Excel table form (this is preferable.):
http://i1279.photobucket.com/albums/y531/tpbest33/wanted_output_zps2c35208e.jpg
(Sorry, but I don't know how to write an html code to show the image.)
I am experimenting with a couple of Stata basic commands and packages: .uselabel, .labutil2, .valtovar., and others. Any help would be appreciated!
1 Answer 1
If you are comfortable working with JSON data, the jsonio program can export the entire dataset as a JSON object and/or write the JSON to a file. There is an option that also will print all of the meta data (e.g., variable labels, value labels, variable names, etc...) in the JSON object. If you wanted to see an example, you can view the README of the project's GitHub Repository. The README shows examples of what the output looks like using the auto.dta data set.
export excel. A wild guess is that you will have to copy-and-pastenotesad hoc. It is expecting too much to hope that Excel and Stata ideas will all line up one to one.