Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: RE: FW: producing value labels when value has decimal point |

Date |
Wed, 11 Aug 2010 21:34:48 +0100 |

Eric's suggestion of multiplying by 10 probably has fewer potential pitfalls ahead. Nick n.j.cox@durham.ac.uk -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: 11 August 2010 21:31 To: statalist@hsphsun2.harvard.edu Subject: st: RE: FW: producing value labels when value has decimal point You have a bundle of problems simultaneously: 1. As the help for -label- clearly states, value labels may be attached to integers. What is more, they may only be attached to integers. That is absolute. 2. Most decimal values -- 1.1 is a leading example -- cannot be held exactly in Stata because they do not have exact binary equivalents. This is well documented in various FAQs and articles. -search precision- points to some references. This precision problem underlies your difficulties with testing for equality with 1.2 and so forth. 3. You can't -recast- from numeric to string or vice versa. The help should be a bit clearer on this. You must use -string()- or -tostring- for that purpose. One possible variable type for your codes is string. But it would also be possible to use integer values 1, 2, etc. and value labels 1 <=> "1.1 Diarrhea", and so forth. label define codes 1 "1.1 Nausea and vomiting" 2 "1.2 Diarrhea" 3 "2.1 Hepatitis" 4 "2.2 "Transaninase increase" <etc> ; And then look at -mencode- from SSC. Nick n.j.cox@durham.ac.uk Miller, Ann C. I have been given a float variable in which the values are things like 1.1 ,1.2, 2.1, 2.2, 2.3. These values correspond to diagnoses in a medical record, for example 1.1=diarrhea, 1.2=nausea/vomiting/other GI . and so on. I would like to create labels for this variable,but so far have been unable. I created a program to do this (see below) but the error message I got back was "may not label 1.1". I then tried to create a cloned variable and "recast" it as a string, and got the error message "string invalid". Then I tried replacing the decimal points by using "replace clonese_code1=12 if clonese_code1==1.2 " and got "0 real changes made" despite there being 67 of them with a code of 1.2. Do you have any suggestions about what I'm doing wrong here? There are 10 variables with the same value codes corresponding to 10 possible episodes of a side effect. My eventual objective is to try to identify if a person has at any time had (for example) hepatitis as a side effect in any of the 10 visits. Any advice about what I'm doing wrong here would be most appreciated. PS: My program was as follows: # delimit ; lab def se_code1 1.1 "Nausea and vomiting" 1.2"Diarrhea" 2.1"Hepatitis" 2.2 "Transaninase increase" 3.1 "Renal insufficiency" 4.1 "Hypothyroidism" 5.1 "Hypokalemia" 6.1 "Arthralgia" 6.2 "Myalgia" 7.1 "Anaphylaxis" 7.2 "Pruritis" 7.3 "Rash" 8.1 "Tinnitus" 8.2 "Ototoxicity" 9.1 "Depression" 9.2 "Psychosis" 10.1 "Peripheral neuropathy" 10.2 "Seizure" 11 "Hypotonia" ; lab val se_code1 se_code1; lab val se_code2 se_code1; lab val se_code3 se_code1; lab val se_code4 se_code1; lab val se_code5 se_code1; lab val se_code6 se_code1; lab val se_code7 se_code1; lab val se_code8 se_code1; lab val se_code9 se_code1; lab val se_code10 se_code1; # delimit cr * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/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/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**st: RE: RE: RE: FW: producing value labels when value has decimal point***From:*"Miller, Ann C." <Ann_Miller@hms.harvard.edu>

**References**:**st: FW: producing value labels when value has decimal point***From:*"Miller, Ann C." <Ann_Miller@hms.harvard.edu>

**st: RE: FW: producing value labels when value has decimal point***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: Intraclass Correlation for an Independent Variable?** - Next by Date:
**st: RE: RE: RE: RE: FW: producing value labels when value has decimal point** - Previous by thread:
**RE: st: RE: FW: producing value labels when value has decimal point** - Next by thread:
**st: RE: RE: RE: FW: producing value labels when value has decimal point** - Index(es):