Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Education CIP Codes with Label Define


From   David Kantor <[email protected]>
To   [email protected]
Subject   RE: st: Education CIP Codes with Label Define
Date   Thu, 08 Jan 2004 10:07:01 -0500

At 09:36 AM 1/8/2004 -0500, John Milam wrote:
Nick,

You are right in the example I included.  I would like then to change it
from string to numeric.  But I don't know how to treat the padding of
leading/trailing zeros and the period which will then treat the number
as having 4 decimals.

Please advise. Many thanks,
John
You should be aware that value labels are definable only for integer values, so that once you have put your variable into a numeric (float or double), you cannot define a corresponding value label.

But, if these values always have 4 decimal places, then you can create a modified version by multiplying by 10000. I would also put in a -round- operation as well.

gen double numvar = real(original_string_var)
gen long new_numvar = round(numvar * 10000)

/* Of course, you could do that in one step if you wanted. )

label define label_cipcode 11110 "Something different for test" ///
990000 "Award"

label val new_numvar label_cipcode

----
I hope this helps.
-- David

David Kantor
Institute for Policy Studies
Johns Hopkins University
[email protected]
410-516-5404

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index