Hello Michael
My understanding is that the general setting (parameters) are automatically set up when the variable is not new. So, when you type generate you are creating a new variable that will take on the type as declared in set type. However, the command replace does not create a new variable. The option nopromote prevents Stata from doing this.
HTH
Hind
-----Original Message-----
> Date: Tue Oct 23 17:09:25 PDT 2007
> From: "Michael Mitchell" <[email protected]>
> Subject: st: Float or Double?
> To: [email protected]
>
> Greetings
>
> While showing someone the merits of "set type double", I encountered
> the strangest thing. After entering "set type double", new non-integer
> variables created via "generate" are created as doubles, but
> non-integer variables created via "replace" are created as floats. For
> example...
>
> . desc
>
> Contains data from hsb2.dta
> obs: 200 highschool and beyond (200
> cases)
> vars: 11 6 Feb 2007 12:41
> size: 3,200 (99.9% of memory free)
> -------------------------------------------------------------------------------
> storage display value
> variable name type format label variable label
> -------------------------------------------------------------------------------
> id int %9.0g
> -------------------------------------------------------------------------------
> Sorted by:
>
> . set type double
> . generate id2 = id / 5
> . replace id = id / 5
> id was int now float
> (200 real changes made)
>
> . desc
>
> Contains data from hsb2.dta
> obs: 200 highschool and beyond (200
> cases)
> vars: 12 6 Feb 2007 12:41
> size: 5,200 (99.9% of memory free)
> -------------------------------------------------------------------------------
> storage display value
> variable name type format label variable label
> -------------------------------------------------------------------------------
> id float %9.0g
> id2 double %10.0g
> -------------------------------------------------------------------------------
> Sorted by:
> Note: dataset has changed since last saved
>
> Shouldn't both "id" and "id2" both be double?
>
> Michael Mitchell
> *
> * 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/
*
* 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/