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: data manipulation prob.


From   tashi lama <[email protected]>
To   <[email protected]>
Subject   st: data manipulation prob.
Date   Wed, 6 Jun 2012 21:24:55 +0000

Hello all, 

   I think I should seek some help here. I tried but to no avail. Here is the prob...

 

              date           hits |
     |---------------------------|
  1. | 10mar2011 01:07:18      1 |
  2. | 10mar2011 01:09:48      1 |
  3. | 10mar2011 01:54:00      1 |
  4. | 10mar2011 02:03:37      1 |
  5. | 10mar2011 02:11:00      1 |
     |---------------------------|
  6. | 10mar2011 02:26:00      1 |
  7. | 10mar2011 02:46:00      1 |
  8. | 10mar2011 02:47:00      1 |
  9. | 10mar2011 02:51:09      1 |
 10. | 10mar2011 02:51:24      1 |

 

 

I need to find the time taken to get half of the total hits

 

summ hits

gen runsum=sum(hits)

 

 

           date              hits     x |
     |---------------------------------|
  1. | 10mar2011 01:07:18      1     1 |
  2. | 10mar2011 01:09:48      1     2 |
  3. | 10mar2011 01:54:00      1     3 |
  4. | 10mar2011 02:03:37      1     4 |
  5. | 10mar2011 02:11:00      1     5 |
     |---------------------------------|
  6. | 10mar2011 02:26:00      1     6 |
  7. | 10mar2011 02:46:00      1     7 |
  8. | 10mar2011 02:47:00      1     8 |
  9. | 10mar2011 02:51:09      1     9 |
 10. | 10mar2011 02:51:24      1    10 |


Now, the prob I am having is I will be comparing r(sum) in var "x" but I need to compute in var "date". So, if r(sum)/2 is 5 then i know to subtract date[5]-date[1]. Any idea?

Also, is it possible to add one date observation on top in date column programmatically. So, I need to add 07mar2011 03:00:00 in date column and because this date comes first than other obs  in the dataset, I need to make this as my first obs. 

 

Any ideas will be highly appreciated..

 

Thanx,

Tashi

 

 

 

 

   

 

 

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