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: RE: RE: RE: stack related (simple) problem


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: RE: RE: stack related (simple) problem
Date   Thu, 3 Mar 2011 20:56:43 +0000

I can't see that there should be _any_ problem to fix. Try 

clear 
input v1 v2 v3
11 12 13
11 12 13
11 12 13
21 22 23
21 22 23
21 22 23
31 32 33
31 32 33
31 32 33
end 
gen id = _n 
reshape long v, i(id)

If you are not getting sensible results from your real data, you need to tell us more, including more about your real data and your code. 

Nick 
[email protected] 

Enayetur Raheem

Thanks a lot, Nick. The duplicates do not show up in the transformed
data, and that is why I was having trouble reshaping it (as I was not
getting the desired results). 

I guess, I will use some sort of loops to delete the duplicate rows from
the first example, and then apply -reshape-.

Nick Cox

Note that we can't comment on what you didn't understand if you don't
show us any code. 

I wouldn't -stack- this. 

I would -reshape-. 

The main reason is that -reshape- is very useful, but you need to
practise so that you can get used to it. I assume an identifier -id-. If
one does not exist, create it. 

gen id = _n 

reshape long v, i(id) 

You can -stack- too. 

stack v1 v2 v3, into(v4) clear 

I don't understand why the duplicates in your first example don't show
up in your second. I assume that's meaningless unless you explain to the
contrary. 

Nick
[email protected] 

Enayetur Raheem
 
I was trying to transform the following data 
 
v1 v2 v3
11 12 13
11 12 13
11 12 13
21 22 23
21 22 23
21 22 23
31 32 33
31 32 33
31 32 33
 
into a single variable, such as 
 
v4
11
12
13
21
22
23
31
32
33

I tried the -stack - command, but could not get it done. I am very new
to Stata, so I am not aware of many commands. Any suggestion will be
much appreciated. 

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