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]

st: Numbers with decimals and -float- command


From   Joseph Monte <[email protected]>
To   statalist <[email protected]>
Subject   st: Numbers with decimals and -float- command
Date   Mon, 7 Nov 2011 19:47:40 +0000

Dear Statalisters,

The output below should contain only observations where there are both
upwards and downwards (or vice versa) movements in "totsh" (from
"totsh1" through "totsho~r"). Sideways movements are allowed. As an
example, obs 1157 has a downward movement from "totsh1" to "totsh2"
then upward to "totsh3" and then sideways to "totsho~r", which is
fine. "obs" is the number of "totsh*" observations in each row.

However, notice observations 1870 (where the path is upward and NOT
downward) & 3275 (where the path is downward and NOT upward). These
observations should not be in type 3 but in type 1 (which captures
upward (and sideways) movements) and type 2 (which captures downward
(and sideways) movements respectively) - these are not shown for
brevity. On further investigation, I expected the issue to be resolved
if I used the -float- command from Nick's FAQ.

http://www.stata.com/support/faqs/data/float.html

However, as shown below, the -float- command does not seem to solve
the problem. In obs 1870, totsh1 & totsh2 do not seem to be equal even
though both are 2.325. Same issue for obs 3275.


. list totsh1 totsh2 totsh3 totsh4 totsh5 totshoffer obs type if type==3

      +----------------------------------------------------------------------------+
      |   totsh1     totsh2     totsh3     totsh4   totsh5   totsho~r
 obs   type |
      |----------------------------------------------------------------------------|
1157. |      3.5   3.483289        3.5          .        .        3.5
   4      3 |
1362. | 1.615159   1.588584          .          .        .          2
   3      3 |
1543. |      1.5          2          .          .        .       1.75
   3      3 |
1691. |       20         25         21         15        .         15
   5      3 |
1762. |     1.75        1.9          .          .        .      1.865
   3      3 |
      |----------------------------------------------------------------------------|
1764. | 1.785918    1.68277          .          .        .        2.4
   3      3 |
1768. |     2.25          2          .          .        .   2.666667
   3      3 |
1771. |      2.5        2.5          3          .        .        2.9
   4      3 |
1774. |      5.5          4        4.7       4.65     4.65       4.65
   6      3 |
1870. |    2.325      2.325      2.525          .        .      2.525
   4      3 |
      |----------------------------------------------------------------------------|
2115. |    2.475       2.14        2.4          .        .        2.4
   4      3 |
2256. |      2.1       1.85          .          .        .        2.1
   3      3 |
2514. |      2.5       2.75          .          .        .        2.4
   3      3 |
2524. |        4        2.7        2.2          2        .        2.2
   5      3 |
2598. |      2.5          2       2.35          .        .        2.5
   4      3 |
      |----------------------------------------------------------------------------|
2606. |      3.7       2.75          .          .        .       2.85
   3      3 |
2645. |      3.4        2.3        3.3          .        .          3
   4      3 |
2657. |      2.3        2.5        2.1       1.65        .       1.65
   5      3 |
2719. |      2.5   2.949862          .          .        .        2.5
   3      3 |
2737. |        2        1.5          .          .        .        1.7
   3      3 |
      |----------------------------------------------------------------------------|
2760. |        1        1.2         .9          .        .         .9
   4      3 |
2782. |     2.25          2          .          .        .        2.5
   3      3 |
2838. |    5.883          4          .          .        .        4.8
   3      3 |
2912. |        2      2.455        1.8          .        .        1.8
   4      3 |
2962. |     1.15          1       1.05          .        .       1.05
   4      3 |
      |----------------------------------------------------------------------------|
2980. |      2.7          2        2.3          .        .        2.3
   4      3 |
2987. |        2        1.4        1.6          .        .       1.92
   4      3 |
3027. |     5.45       5.55       5.65      5.553        .      5.553
   5      3 |
3096. |      1.8       1.85       1.25       1.35        .       1.35
   5      3 |
3132. |      1.5          1       1.25          .        .       1.25
   4      3 |
      |----------------------------------------------------------------------------|
3188. |      2.3        2.7          .          .        .        2.3
   3      3 |
3251. |     17.2          6          .          .        .          7
   3      3 |
3275. |      6.8        6.8          5          .        .          5
   4      3 |
3286. |      1.8        1.4        1.5          .        .        1.5
   4      3 |
3306. |        6          4          5          .        .          5
   4      3 |
      |----------------------------------------------------------------------------|
3488. |      2.5        2.2        2.5          .        .        2.5
   4      3 |
3519. |    16.25      13.25       13.3       14.9        .       14.9
   5      3 |
3566. |   12.575       10.5          5     4.0625        .      4.665
   5      3 |
3667. |      3.5          4        3.6          .        .        3.6
   4      3 |
3877. |     6.25        5.5        6.5          .        .        6.5
   4      3 |
      |----------------------------------------------------------------------------|
3919. |        8       11.5        8.5          .        .        8.5
   4      3 |
3944. |      7.5        4.7          .          .        .          5
   3      3 |
3954. |        6          5          .          .        .       6.44
   3      3 |
4002. |     10.3       14.6         10          .        .         10
   4      3 |
4014. |        5       4.95   5.030305   5.045972        .   5.295972
   5      3 |
      +----------------------------------------------------------------------------+

. list totsh1 totsh2 type if float(totsh1)==float(totsh2) & totsh1!=. & type==3

      +------------------------+
      | totsh1   totsh2   type |
      |------------------------|
1771. |    2.5      2.5      3 |
      +------------------------+

. des totsh1 totsh2

              storage  display     value
variable name   type   format      label      variable label
---------------------------------------------------------------------------------------------------------------------------------------------
totsh1          float  %9.0g
totsh2          float  %9.0g


I would appreciate any help on the issue. I am using Stata 12.

Thanks,

Joe
*
*   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