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: Reshape from long to wide and attaching Labels contained in a Variable.


From   "Sarah Edgington" <[email protected]>
To   <[email protected]>
Subject   st: RE: Reshape from long to wide and attaching Labels contained in a Variable.
Date   Thu, 29 Aug 2013 16:31:09 -0700

Stefan,
It would be helpful to see what the actual command you used to reshape your data was.  Either the example you're showing below isn't what your data actually looks like or there's a lot you aren't saying about the reshaping process.
I'm assuming you reshaped with code something like:
reshape wide title amount, i(id) j(code)
However, your example can't be reshaped that way since code repeats within an ID.  Plus your example doesn't include a reshape of Title (which, again, will produce an error if you try to reshape the example you show).

If you show actual code and example data that has the same structure as your real data someone may be able to offer more specific advice.  As it is, what you've given here isn't enough for me to grasp what you've accomplished so far, much less exactly what you're trying to accomplish.

Given the example you've shown, what you want to do seems impossible to me.  You have a single code "yy4" with two different titles.  How would you decide which label the final yy4 variable gets (I'm assuming what you're trying to do is attach variable labels; I may be wrong about that)?

-Sarah

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of "Stefan Schöftner"
Sent: Thursday, August 29, 2013 2:11 PM
To: [email protected]
Subject: st: Reshape from long to wide and attaching Labels contained in a Variable.

 

Hello Dear Statalist subscribers,
 
As a fellow reader, i now dare to post my first own question.
I got actually a rather simple looking issue but it seems not doable also i worked on it for several days
 
I got a  sample of a Data file looking something like this:
 
Long FORM:
ID´s repeat therefor i need the wide form.
 
Obs.          ID       Title             Amount                Code
1              xxx       abc              12345                   yy1
2              xxx       bcd              54321                   yy2
3              xxx       cda              43215                   yy3
4              xxx       acb              32154                   yy4
5              xxx       cad              21543                   yy4
 
 
I use a reshape command to bring this dataset into wide form so it looks like this
 
Wide Form:
 
Obs.          ID        yy1      yy2    yy3    yy4      yy5        Title       

1              xxx                                                  abc
2              xxx                                                  bcd
3              xxx      AMOUNT ---------------------Amount          cda
4              xxx                                                  acb
5              xxx                                                  cad
 
What I now desire, would be that the variable "Title" be converted into  the label text for the according variables yy1-yy5-yyx.
yyx because the entire dataset consists of several 10.000 observations The variable "code" itself would be enough for identification but since im going to work a lot more with this sample the change in Label would help me quite a bit.
 
At the current point in time i just drop "Title" and deal with the Coding.
I would really appreciate any input on how to solve this issue.
 
Best Regards and Thanks in Advance
Stefan
 

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


*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index