label define carlabel 0 "Foreign" 1 "Domestic" To assignĪppropriate labels, you would use the following commands. Both variables were coded 0 for foreign and 1įor domestic. The respondents were asked whether the car they were trading To manually specify the same labels for n variables n different times.įor example, suppose you have data on the purchasing habits of carīuyers. One particular mapping with multiple variables, making it unnecessary
With this two-step process, you can associate The second step is to associateĪ specific mapping with a particular variable using the. label defineĬommand to create a mapping between numeric values and the words or Information here may no longer be accurate, and links may no longer be available or reliable.Īdding a value label to a variable in Stata is a two-step
#Label define stata download
However, it does the trick for the example data: It can (1) download the DDI XML file, (2) read all labels (including variable labels) from it, and (3) apply these labels to the (example) dataset in memory.This content has been archived, and is no longer maintained by Indiana University. More or less, it is a quick shot for XML parsing, specialized on this very specific XML DDI file.
#Label define stata code
It's not the most efficient or elegant code snippet I have ever produced, sorry. So I sat down to produce some example code. This plaintext XML file contains all we need, so we can read this into Stata (with - file-, as Daniel demonstrated), and label everything accordingly.
Surfing around on the data provider's website, I found that they provide a DDI (1.2.2 - this is a quite old format) metadata file for download in the section " Study Description -> Download Metadata". Sorry, this will get a little excessive now. After I read his solution, I followed the hyperlink Anustup Kundu posted in #9. I fully agree with daniel klein that it would be best to save the metadata (value labels etc) to a plain text file, and parse it afterwards. I stumbled upon this post about two hours ago. House rent, garage rent (imputed- urban only)Ĭonsumer taxes and cesses: sub-total (540-541) Petrol, other fuels & lubricants for vehicle Other consumer services excluding conveyanceĬonsumer services excluding conveyance: sub-total (480-496) Goods for personal care and effects: sub-total (440-445)īucket, water bottle/ feeding bottle & other plastic goods Other goods for personal care and effects Medical – non-institutional: sub-total (420-428) for example, can stata read a codebook somehow and label them accordingly? I want to know if there is a smarter way how I can approach this.
Label define B3_q10 1 "pucca" 2 "semi pucca" 3 "serviceable katcha" 4 "unserviceable katcha" 5 "no structures" Label define B3_q5 1 "Hinduism" 2 "Islam" 3 "Christianity" 4 "Sikhism" 5 "Jainism" 6 "Buddhism" 7 "Zoroastrianism" 9 "others" Labelling them in the manner below manually would be quite demanding However B5_q1 has values 100,101,102.,339 signifying different food for example 100 signifies rice 101 signifies potato 102 signifies radish, etc.ī10_q1 has values 420,421,422.,549 signifying expenditure on various things such as 420 signifies medical expense, 430 signifies movies expense, etc. Input byte(B3_q5 B3_q10) int(B5_q1 B10_q1)ī3_q5=religion having values Hinduism-1, Islam-2, Christianity –3, Sikhism-4, Jainism-5, Buddhism-6, Zoroastrianism-7, others-9ī3_q10= type of house structure: pucca-1, semi-pucca-2, serviceable katcha –3, unserviceable katcha – 4, no structure-5