Statalist


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

RE: st: AW: numeric format


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   RE: st: AW: numeric format
Date   Fri, 14 Aug 2009 21:22:46 +0200

<>

Ok, so here is code that

a) runs under 9.2
b) contains counts
that 
b1) are exponentiated if left to their own devices
b2) behave as you want with the -format- option to -table-



***

version 9.2
clear

set obs 10000000

gen byte id=uniform()<0.6  
gen byte secondid=1
table id secondid, row col format(%18.0fc)
***


HTH
Martin

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Sandra Rayman
Sent: Freitag, 14. August 2009 21:02
To: [email protected]
Subject: Re: st: AW: numeric format

That is exactly what I want - to get a count of the combinations of
the variables involved! As I am simply counting the number of people
in each racial group in each year in my survey data - my original code
was -table date race [fweight = weight], format(%15.0g)-. Using the
-mean-coding simply averages out the codes for the different racial
groups - definately not what I want. The table in my coding is what I
need, the only problem is the exponential format as this does not
allow me to see the actual number in each group. Surely there must be
a way in Stata to get such a basic table with the actual numbers?

Yours,
Sandy

On Fri, Aug 14, 2009 at 8:27 PM, Martin Weiss<[email protected]> wrote:
>
> <>
>
> There lies the rub. If you say table x id, you get a count of the
> combinations of variables involved - which is 1000 following Nick`s
> modification -, so you should still use the code where the mean is
> calculated to get a big number...
>
>
> HTH
> Martin
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Sandra Rayman
> Sent: Freitag, 14. August 2009 20:20
> To: [email protected]
> Subject: Re: st: AW: numeric format
>
> Thank you. I am now able to get the example code working, but it still
> does not solve my problem of how, in general, to get a table in
> non-exponential format.
>
> For example, if (using the example) I say -table x id, format(%18.0fc)- I
> get:
>
> ------------------------------
>          |         id
>        x |                  1
> ----------+-------------------
>  1.00e+12 |              1,000
> ------------------------------
>
> And I get the same result if I say -table x id, format(%18.0fc)-. The
> example works, where id is just 1 throughout, but that is not the kind
> of table I need as it just gives the mean of the variable I am
> interested in. I am still trying to get a basic table (as per the
> comand above) with the actual numbers showing in non-exponential
> format. Sorry to keep bothering people with this question but I am
> just sure that there must be a simple way around it...
>
> Yours,
> Sandy.
>
>
>
>
> On Fri, Aug 14, 2009 at 7:49 PM, Nick Cox<[email protected]> wrote:
>> -rnormal()- was introduced during the lifetime of Stata 10.
>>
>> The FAQ new members are asked to read asks users to make clear whether
> they are using an out-of-date version; the current version is 11.
>>
>> The equivalent command for Stata 9.2 uses -invnormal(uniform())-
>>
>> However, as you guessed, that detail is irrelevant to your problem.
>>
>> This code worked for me with Stata 10.1. I no longer have Stata 9.2 on my
> machine:
>>
>> . clear
>>
>> . set obs 1000
>> obs was 0, now 1000
>>
>> .
>> . gen x=1e12
>>
>> .
>> . gen id =_n<=5000
>>
>> .
>> . table id, contents(mean x)
>>
>> ----------------------
>>       id |    mean(x)
>> ----------+-----------
>>        1 |   1.00e+12
>> ----------------------
>>
>> . table id, contents(mean x) /*
>>>   */ format(%18.0fc)
>>
>> ------------------------------
>>       id |            mean(x)
>> ----------+-------------------
>>        1 |    999,999,995,904
>> ------------------------------
>>
>>
>> Nick
>> [email protected]
>>
>> Sandra Rayman
>>
>> Thank for for the prompt reply. I am unable to follow the suggested
>> code exactly as the 'rnormal' part gives me an error message that it
>> is an unknown function (perhaps because I am using Stata 9.2).
>> However, looking through the rest of the suggested code I thought that
>> the key part might be 'format(%11.0fc)', so I tried this but still
>> without success. Specifically, I tried
>> table date race [fweight = weight], format(%15.0fc) and several
>> variations of this, but the numbers are still presented in exponential
>> format. What am I missing here?
>>
>> Thanks for clarification or any other suggestions.
>>
>> 2009/8/14 Martin Weiss <[email protected]>:
>>
>>> *************
>>> clear*
>>> set obs 10000
>>>
>>> gen x=rnormal(10000000)
>>>
>>> gen id =_n<=5000
>>>
>>> table id, contents(mean x)
>>> table id, contents(mean x) /*
>>>  */ format(%11.0fc)
>>> *************
>>
>> Sandra Rayman
>>
>>> This is my first question to Statalist, and I'm afraid it's a bit of a
>>> basic one. I need a basic table of statistics and the problem I am
>>> having is that the numbers are shown in exponential rather than
>>> regular format. From the help function I read how to use the format
>>> command but the problem remains.
>>>
>>> I am using survey data and just need a basic table of the number of
>>> people, in each year, by race. The command I am using is:
>>> table date race [fweight = weight], format(%15.0g)
>>>
>>> I have tried increasing the number in the format command more and more
>>> (e.g. format(%18.0g)) but all that happens is that the columns get
>>> wider and the numbers are shown as e.g. 1.16e+07 whereas I need the
>>> full numbers. I know this should be easy, but from the help function
>>> and statalist archive I can't figure out how to do it.
>>
>> *
>> *   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/
>

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index