Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

RE: st: variable format (graphics example)


From   "Feiveson, Alan H. (JSC-SK311)" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: variable format (graphics example)
Date   Thu, 10 Mar 2011 15:30:33 -0600

As an example, try this:


. set obs 4
obs was 0, now 4

. gen u = uniform()
. gen ru = round(u,.01)
. expand 10
(36 observations created)

. gen y = rnormal()
. gen x = y+rnormal()

. scatter y x,by(ru)


Al Feiveson


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Joerg Luedicke
Sent: Thursday, March 10, 2011 2:02 PM
To: [email protected]
Subject: Re: st: variable format

2011/3/10 Andreas Drichoutis <[email protected]>:
> Well it didn't. I tried gen varnew=round(var,.01) and all it did is to
> create a copy of the original variable. Values are displayed with 2 decimals
> but the actual value is 7 decimals long.
>

well, it should work. What happens if you try the following:

clear all
set obs 100
gen x=runiform()+1
gen x2=round(x,.01)

That works for me.

J.
*
*   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/



-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Feiveson, Alan H. (JSC-SK311)
Sent: Thursday, March 10, 2011 3:23 PM
To: [email protected]
Subject: RE: st: variable format

Hi - I have come across this problem before when I wanted to use the value of a variable or macro in a graphics title or axis label. Rounding doesn't work. I had to convert the values to strings and snip off the offending decimals (too much work).

Al Feiveson

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Daniel Klein
Sent: Thursday, March 10, 2011 2:09 PM
To: [email protected]
Subject: Re: st: variable format

Dear Andreas,

since it is not possible to store values like 8.77 exactly, like Maarten already mentioned, you might want to tell us more about the reason, why you want your variables to only have two decimals. Maybe there is another way to solve the underlying problem. 
-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
*
*   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/

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index