Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Verify that all values of a variable are mapped after -label values-
From
Robert Picard <[email protected]>
To
[email protected]
Subject
Re: st: Verify that all values of a variable are mapped after -label values-
Date
Thu, 20 Jun 2013 16:13:32 -0400
You can use -decode- to convert your numeric variable to string. Any
value not mapped to a label will be missing. For example:
. sysuse auto, clear
(1978 Automobile Data)
. replace foreign = _n in 1/5
(5 real changes made)
. tab foreign
Car type | Freq. Percent Cum.
------------+-----------------------------------
Domestic | 47 63.51 63.51
Foreign | 23 31.08 94.59
2 | 1 1.35 95.95
3 | 1 1.35 97.30
4 | 1 1.35 98.65
5 | 1 1.35 100.00
------------+-----------------------------------
Total | 74 100.00
. decode foreign, gen(s)
. tab foreign if mi(s)
Car type | Freq. Percent Cum.
------------+-----------------------------------
2 | 1 25.00 25.00
3 | 1 25.00 50.00
4 | 1 25.00 75.00
5 | 1 25.00 100.00
------------+-----------------------------------
Total | 4 100.00
Robert
On Thu, Jun 20, 2013 at 3:57 PM, <[email protected]> wrote:
> try the -labelbook- command with the "problem" option
>
> Rich
>
>
> -----Original Message-----
>>From: Toby Robertson <[email protected]>
>>Sent: Jun 20, 2013 3:48 PM
>>To: "[email protected]" <[email protected]>
>>Subject: st: Verify that all values of a variable are mapped after -label values-
>>
>>What is the easiest way to check whether, having applied a value label to a variable...
>>
>> label values myvar mylabel
>>
>>...every value of myvar in the dataset is mapped to mylabel?
>>
>>I am using Stata 10, creating value labels from lookup files from numeric code variables to string descriptor variables using -labmask- followed by -label save-, and then applying them to the values of the numeric variables in very large datasets.
>>
>>The obvious solution might be to merge the string variable itself from the lookup file into the target file (after which I could check the integrity of the merge, use -labmask-, and drop the string variable again) because I want to avoid that because of file size and read time considerations.
>>
>>Thanks in advance to anyone who knows the answer offhand!
>>
>>Toby
>>*
>>* For searches and help try:
>>* http://www.stata.com/help.cgi?search
>>* http://www.stata.com/support/faqs/resources/statalist-faq/
>>* http://www.ats.ucla.edu/stat/stata/
>
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/