Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Reshape Data


From   [email protected]
To   [email protected]
Subject   Re: st: Reshape Data
Date   Tue, 15 Feb 2005 13:15:35 -0600

If we assume you have legal variable names, the following should work:

. l

     +-------------------------------+
     |      code   v890216   v691693 |
     |-------------------------------|
  1. | 5/15/1995         0         . |
  2. | 5/16/1995         0        .1 |
  3. | 5/17/1995         0        .2 |
  4. | 5/22/1995         .        .2 |
  5. | 5/23/1995         0        .2 |
     +-------------------------------+

. reshape long  v , i(code) j(firm)
(note: j = 691693 890216)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                        5   ->      10
Number of variables                   3   ->       3
j variable (2 values)                     ->   firm
xij variables:
                        v691693 v890216   ->   v
-----------------------------------------------------------------------------

. sort firm code

. l

     +-------------------------+
     |      code     firm    v |
     |-------------------------|
  1. | 5/15/1995   691693    . |
  2. | 5/16/1995   691693   .1 |
  3. | 5/17/1995   691693   .2 |
  4. | 5/22/1995   691693   .2 |
  5. | 5/23/1995   691693   .2 |
     |-------------------------|
  6. | 5/15/1995   890216    0 |
  7. | 5/16/1995   890216    0 |
  8. | 5/17/1995   890216    0 |
  9. | 5/22/1995   890216    . |
 10. | 5/23/1995   890216    0 |
     +-------------------------+


Scott
 


----- Original Message -----
From: Susan Flaherty <[email protected]>
Date: Tuesday, February 15, 2005 12:31 pm
Subject: st: Reshape Data

> 
> Dear All,
> I have an unusual dataset that I am trying to reshape, and the ususal
> commands don't seem to apply.
> An example of the data is as follows:
> 
> Code	890216(VO)                     691693(VO)
> 5/15/1995	0                                               .
> 5/16/1995	0                              0.1
> 5/17/1995	0                                      0.2
> 5/22/1995	.                                      0.2
> 5/23/1995	0                                      0.2
> 
> I would like to obtain a standard panel (long format) so that I 
> can run
> some regressions:
> 
> FIRM	DATE             TURNOVER
> 890216	5/15/1995	0                                               
> 	5/16/1995	0                              
> 	5/17/1995	0                                      
> 	5/22/1995	.                                      
> 	5/23/1995	0                                     
> 691693	5/15/1995	.
> 	5/16/1995	0.1
> 	5/17/1995	0.2
> 	5/22/1995	0.2
> 	5/23/1995	0.2
> 	
> 
> The only unique identifier is the firm number (890216(VO)), and the
> stem of the common text is the suffix rather than the prefix (e.g.
> inc_90 inc_91 inc_92). 
> 
> I am currently trying something like:
> .  reshape datafile 890216, i(code) j(turnover) string
> 
> But since the prefix is a unique number, I can't  replace the unique
> number thousands of times.
> I would greatly appreciate any suggestions on how to reformat the
> data.
> 
> Thank you and regards,
> Susan Flaherty
>


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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