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.

# Re: st: programming error with -generate-

 From Stas Kolenikov To statalist@hsphsun2.harvard.edu Subject Re: st: programming error with -generate- Date Mon, 8 Mar 2010 16:22:43 -0600

```OK, here's the synopsis:

1.2x is hexadecimal, i.e. 1.2x = 1 + 2/16 = 1.125 decimal.

Now, the interesting part is that "+6" in the original post means "move the
decimal point 6 times to the right":

forvalues k=0/6 {
di 1.2x + `k'
}

In the muggles' world, "move the decimal point one position to the right"
means "multiply by 2". So it looks like the whole meaning of the spell
"1.2x+6" is actually a number in a hexidecimal representation with an
implicit exponentiation:

di (1.2x+6) - ((1+2/16)*2^6)

On Mon, Mar 8, 2010 at 4:14 PM, Lachenbruch, Peter <
Peter.Lachenbruch@oregonstate.edu> wrote:

> But then it seems to take 12 and multiply by 6 to get 72.  This is the kind
> of arithmetic my students sometimes do... :-)
>
> Tony
>
> Peter A. Lachenbruch
> Department of Public Health
> Oregon State University
> Corvallis, OR 97330
> Phone: 541-737-3832
> FAX: 541-737-4001
>
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:
> owner-statalist@hsphsun2.harvard.edu] On Behalf Of Richard Williams
> Sent: Monday, March 08, 2010 1:51 PM
> To: statalist@hsphsun2.harvard.edu; 'statalist@hsphsun2.harvard.edu'
> Subject: Re: st: programming error with -generate-
>
> At 04:31 PM 3/8/2010, Visintainer, Paul wrote:
> >. gen y = 1.2x + 6   <----- why isn't there an error here?
>
> When I do this, y = 72 for all cases.  So 1.2x must be getting
> interpreted as 1.2 * 10 = 12.  I don't know why, but just follow
> Martin's advice and make it
>
> gen y = 1.2*x + 6
>
> Maybe this is a "feature" but if so it doesn't seem like a good one,
> since this could be an easy mistake to make.
>
>

--
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

*
*   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/```