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: How to copy the contents of a variable into a new variable but in different observations


From   Clarice Martins <martins.clarice@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: How to copy the contents of a variable into a new variable but in different observations
Date   Sat, 26 Oct 2013 12:35:02 -0200

Thanks, Sergiy!
Your comments were the most helpful.
I will try the suggested.


Regards,
Clarice

Sent from my iPad

> On Oct 22, 2013, at 8:35 PM, Sergiy Radyakin <serjradyakin@gmail.com> wrote:
> 
> Clarince,
> 
> read help for the command: merge. At least it sounds to me that this
> is the most relevant in your case, but I don't completely understand
> your setup. Read the section 3.2 here:
> http://www.stata.com/support/faqs/resources/statalist-faq/#question
> 
> I suggest: separate your data into two parts: final sample (with
> potentially not all variables present, but the right number of
> observations) and reference (with potentially not all observations,
> but with the variables missing in the first part). Then merge first
> (master) and second (using).
> 
> Your reference data may contain any attribute you want: initial price,
> price in June 2000, temperature in Seattle on the day the CEO was
> born, etc. But there must be a link to match the observations between
> the two. If you have one record by company in the reference data (all
> of the quoted examples) then the stock id should be sufficient,
> otherwise consider also time variable (e.g. price on Jan 1 of the
> actual year, with values of actual year differing for differing
> observations).
> 
> Given the data structure you describe, you might also need the
> -reshape- command. Your data appears to be in 'wide' format. You might
> need to reshape it to long format, before merging.
> 
> Consider creating an example dataset that we could import to Stata to
> see something similar to your data. It doesn't have to be actual
> numbers, but the variables, etc. You get a much higher response rate
> on your questions that way. Because not only one has to come up with
> the solution to your question now, but also first to reproduce the
> situation you have. Note that Stata comes with example datasets, and
> more are available with the manuals, just type help datasets, perhaphs
> there is already an example like your data.
> 
> Best, Sergiy Radyakin
> 
> 
> 
> 
> On Tue, Oct 22, 2013 at 6:03 PM, Clarice Martins
> <martins.clarice@gmail.com> wrote:
>> Hello!!
>> 
>> Can anyone help me with this?
>> 
>> I have data that is set as stock returns for different months (variables: jun2000 jul2000 aug2000 and so on), for different companies (variable: ticker_name) and different types of returns (variable: type_return with 3 groups: "formation_period", "buy_sell_period", "holding_period")
>> 
>> I have separated the Jun2000 returns, for the "formation period" observations, into quintile data. ie: now I have a variable called quintile that ranks from 1111 to 5555, my Jun2000 returns for the formation_period only.
>> 
>> Now, I need to copy these quintile numbers between companies (same companies) from "formation period" observations to "buy sell period" observations.   ie.: if AMBV4 has 1 in the "formation period", i need to carry 1 to AMBV4 in the "buy_sell_period" and "hold period" observations.
>> 
>> Is this possible? What is the best way?
>> 
>> I am new at stata and I have been learning a lot of new things, but I am having difficulty with this... Can you guys give a hand??
>> 
>> Thank you very much!!
>> Clarice
>> 
>> 
>> *
>> *   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/

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