1

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!

Brian Tompsett - 汤莱恩
5,92772 gold badges63 silver badges135 bronze badges
asked Mar 21, 2013 at 2:34
2
  • Not something I ever want to do, but I would not start from where you seem to be looking, which is at user-written extras. I would start with export excel. A wild guess is that you will have to copy-and-paste notes ad hoc. It is expecting too much to hope that Excel and Stata ideas will all line up one to one. Commented Mar 21, 2013 at 12:18
  • Thanks, Nick. I managed to produce the table by using . descsave, .valtovar, . uselabel, and others. For notes, I made a dataset that has the variable and the corresponding note columns, and merge it onto the table I produced before. Commented Mar 24, 2013 at 0:34

1 Answer 1

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.

Nick Cox
37.4k6 gold badges37 silver badges51 bronze badges
answered Nov 7, 2015 at 13:24
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.