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]

AW: st: RE: AW: AW: RE: AW: RE: Transposing datasets


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   AW: st: RE: AW: AW: RE: AW: RE: Transposing datasets
Date   Mon, 2 Aug 2010 15:52:32 +0200

<> 


" Indeed, I have stored datadate in %td- format, which
caused my problems with the reshape command."




The display -format- should not matter at all, I think, for -reshape- purposes. This code runs w/o problems:


*************
clear*

inp gvkey str10	datadate mcap_sum
212782	30jun2005	4946.9
212782	31jul2005	5042.1
212782	31aug2005	5145
212782	30sep2005	5302.5
212782	31oct2005	5253.5
212782	30nov2005	5642.7
212782	31dec2005	6230  
212783	30jun2005	496.9
212783	31jul2005	502.1
212783	31aug2005	515
212783	30sep2005	530.5
212783	31oct2005	523.5
212783	30nov2005	562.7
212783	31dec2005	630  
end

li, noo sepby(gvkey)

gen datadate2=date(datadate, "DMY")
form datadate2 %td

drop datadate

reshape wide mcap, i(gvkey) j(datadate2)

foreach var of varlist mcap_sum*{
	ren `var' `=subinstr("`var'", "mcap_sum", "date_", 1)'
}

l
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Kaspar Dardas
Gesendet: Montag, 2. August 2010 15:44
An: statalist@hsphsun2.harvard.edu
Betreff: Re: st: RE: AW: AW: RE: AW: RE: Transposing datasets

Hey,

thanks guys. Indeed, I have stored datadate in %td- format, which
caused my problems with the reshape command.
Now all works fine.

Best,

Kaspar





2010/8/2 Nick Cox <n.j.cox@durham.ac.uk>:
> No arguments here.
>
> Sometimes we all just want to get results quickly and accurately, and
> care not a jot about logic. Sometimes understanding exactly what is
> going on is the best prescription because it is all too likely that your
> next such problem will not be identical and you will need to know how to
> change the solution.
>
> Nick
> n.j.cox@durham.ac.uk
>
> Martin Weiss
>
> Nick himself advocated "first principles" in
> http://www.stata.com/statalist/archive/2010-05/msg01165.html, btw...
>
> Martin Weiss
>
> "( Also, I learned something about using subinstr() in the rename
> command
> from your post, thanks )"
>
> Cheers! I love to work from first principles whenever possible, so my
> use of
> -subinstr()- was not intended to detract from the appeal of NJC`s
> -findit
> renvars-...
>
> Eric Booth
>
> ( Also, I learned something about using
> subinstr() in the rename command from your post, thanks )
>
> *
> *   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/
>

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


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