Bookmark and Share

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]

Re: st: Re: format


From   Maarten Buis <maartenlbuis@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: format
Date   Mon, 30 Jul 2012 16:21:37 +0200

You can just leave the string in your dataset and create a new numeric
id like this
bys stringid : gen numid = _n == 1
replace numid = sum(numid)

-- Maarten

On Mon, Jul 30, 2012 at 4:16 PM, Chiara Mussida <cmussida@gmail.com> wrote:
> encode works. The only constraint is that it does not encode string
> variables that takes more than 65,536 unique values.
> Thanks
>
> On 29/07/2012, Joseph Coveney <jcoveney@bigplanet.com> wrote:
>> Chiara Mussida wrote:
>>
>> i have a string variable of 18 lenght. This is my id and i need it
>> numerical. I proceeded with destring and i got a numerical variable in
>> double format. I tried to get it in the format %18.0f, but i realised
>> that stata does not maintain the original number. It approx each
>> variable and in this way i cannot get a unique id Per individual. Do
>> you know whether it is a problem of wrong format?
>>
>> --------------------------------------------------------------------------------
>>
>> It is not a problem of the wrong format.  At the command line type:
>>
>>     help data_types
>>
>> and examine the precision of Stata's numerical data types.
>>
>> I'm curious as to why you believe that you must store eighteen-character IDs
>> as
>> numbers.  If you need to obtain a numerical ID for use of one of Stata's
>> -xt-
>> commands, then you can use -encode-.
>>
>> Joseph Coveney
>>
>>
>> *
>> *   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/
>>
>
>
> --
> Chiara Mussida
> PhD candidate
> Doctoral school of Economic Policy
> Catholic University, Piacenza (Italy)
> *
> *   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/



-- 
--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany


http://www.maartenbuis.nl
--------------------------
*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index