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]

Re: st: Problem with merging 2 datasets


From   Paolina Medina <[email protected]>
To   [email protected]
Subject   Re: st: Problem with merging 2 datasets
Date   Mon, 14 Jun 2010 09:28:19 -0500

The interesting thing is that if you have quarterly results they
should not be related to february but to march, june, september and
december...
But anyway if you want to replace february with march data i think
string functions can be useful:

You can generate a varible that indicates you whenever a date is on
february (This is relevant because you have many years).
If the variable when the dates are stored is "date" then:

gen month= substr(date,4,2)

Where 4 is the position where the month begins and 2 is the lenght of the month.

You can also use concat to concatenate different string variables in a
new string:

egen newvar= concat(var1 var2 ...)


Hope this helps...








On Mon, Jun 14, 2010 at 8:49 AM, Thomas Gericks <[email protected]> wrote:
> Hello,
>
> I'm using Stata to analyize the correlation between two data sets. This is my situation:
>
> I have a data set "A" containing economic data for each quarter between 1960 and 2010. Another data set "B" contains the quarterly results between 1960 and 2010 of 5 different companys.
>
> From the manual for the command "merge" I conclude that I want to do merge A and B as a 1:m relationship. Unfortunately the dd.mm.yyyy dates in "A" (31.03.yyyy, 30.06.yyyy., 30.09.yyyy, 31.12.yyyy)
> are not compliant to the company dates which can be 27.02.yyyy instead of 31.03.yyyy. My solution is to replace all February dates with March, January and November with December, etc.
>
> As I have no programming background I'm overstrained with the syntax.
>
> What are the correct commands to
> 1. Take data set "B" and replace all dates in for example February with March and
> 2. Merge "A" and "B" with a 1:m relationship
>
> Best regards,
> Thomas Gericks
> ___________________________________________________________
> GRATIS für alle WEB.DE Nutzer: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://movieflat.web.de
>
> *
> *   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/
>



-- 
Paolina Medina Palma

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