Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: How to transfer strings in different rows of a cell into different observations


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: How to transfer strings in different rows of a cell into different observations
Date   Sat, 22 Jun 2013 17:09:04 +0100

This is an FAQ. Standard Statalist advice is to look at the FAQs before posting.

http://www.stata.com/support/faqs/data-management/replacing-missing-values/

explains that

replace number = number[_n-1] if missing(number)

is a way to do this.

Nick
njcoxstata@gmail.com

On 22 June 2013 17:03, XIAOFEI XING <mike.xf.xing@gmail.com> wrote:

> I have a following format excel file:
>
> Number        ID                Assignment
> 1                   A A                  AS1 E2
>                        B                    AS2 A3
>                        C                   AS3
> 2                    A                    AS6
>                      D F                  AS2
>                        F                   AS10
> 3                  W W                AS9
>
> Take the observation Number 1 as an example, string "A A", "B" and "C" are in the different rows of a same cell of a excel file. Similarly, string "AS1 E2", "AS2 A3" and "AS3" are also in the same cell.
>
> I want to use Stata to transfer different rows of strings into different observations, showing as following:
>
> Number        ID                Assignment
> 1                   A A                  AS1 E2
> 1                     B                   AS2 A3
> 1                     C                    AS3
> 2                     A                    AS6
> 2                   D F                  AS2
> 2                     F                    AS10
> 3                  W W                 AS9
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index