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: pasting into stata


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: pasting into stata
Date   Wed, 18 Sep 2013 14:32:46 +0200

*------------------ begin example ------------------
// input the example data
clear
input ///
entity           time          event
1                1             0
1                2             1
1                3             0
1                4             0
1                5             0
2                1             1
2                2             1
2                3             0
2                4             0
2                5             0
3                1             0
3                2             0
3                3             0
3                4             0
3                5             1
end

// create the variables
// total number of events at time t
bys time : egen num_events = total(event)
// indicator variable any event occured at time t
gen any_event = (num_events >= 1) if num_events < .

// admire the result
sort entity time
list, sepby(entity)
*------------------- end example -------------------
* (For more on examples I sent to the Statalist see:
* http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

On Wed, Sep 18, 2013 at 2:22 PM, Drew Reed wrote:
> I have a panel dataset with 72 different entities, each with 2813
> observations. I created dummies for credit rating news announcements
> for each entity in Stata. Basically, I have collapsed the data within
> Stata to create a new set of 2813 observations, where all of the
> events for each entity is accounted for. The data might look like
> this...
>
> Entity       Time      Event       Collapsed_event
> 1                1             0                       1
> 1                2             1                       1
> 1                3             0                       0
> 1                4             0                       0
> 1                5             0                       1
> 2                1             1
> 2                2             1
> 2                3             0
> 2                4             0
> 2                5             0
> 3                1             0
> 3                2             0
> 3                3             0
> 3                4             0
> 3                5             1
>
> In Stata I can copy this collapsed event but then I need to paste it
> into each entity's observation range. Is there some sort of paste
> command that will allow me to save this collapsed output and then
> paste for each entity? I hope this visualization helped clear up
> anything and yes I agree, Stata is the easiest data modification tool
> I've used so therefore I'd like to keep things in Stata and not fool
> around with Excel.
>
>
>
> On Wed, Sep 18, 2013 at 2:13 PM, Jeph Herrin <[email protected]> wrote:
>> It is not clear what your data look like, or what sort of file you are
>> copying from, but it would almost surely be easier to put all of the data
>> into Stata and use Stata to create the dataset you want.
>>
>>
>> Jeph
>>
>>
>> On 9/18/2013 7:36 AM, Drew Reed wrote:
>>>
>>> Hi,
>>>
>>> I have to paste into Stata in a certain way and I'm hoping someone
>>> knows code that will make this easier for me. I am working with panel
>>> data and need to populate a 'sum' variable so that I can subtract a
>>> variable that contains entity specific information so that I can
>>> produce a spillover variable.
>>>
>>> I have basically collapsed my information by date so that I am given a
>>> sum of all events that have happened during the 2813 days being used
>>> for observations. There are 70 entities I would need to paste this
>>> information into and as of right now the only way I know how to do
>>> this is to go through my dataset manually, filtering by id, and then
>>> putting in the variable.
>>>
>>> Is there a faster way to paste as such? I had originally used a looped
>>> code to try to generate these variables and after a week of running
>>> this code it produced faulty measures. I'd rather just put in the time
>>> and get it right but I'd also like to know if there is a paste option
>>> where I can paste the same data for all id values.
>>>
>>> Thanks in advance.
>>>
>>> Sincerely,
>>>
>>> Drew
>>> *
>>> *   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/



-- 
---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   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