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: Reshape with prefix using a varlist


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Reshape with prefix using a varlist
Date   Tue, 15 Mar 2011 01:02:06 +0000

Thanks. That clarifies some things but not others. In your example,
you have 7 headings but 6 columns of data. What is
"country1-country244"? A variable label?

The totals for groups are easily computable using -egen, total()- with
your present structure.

On Tue, Mar 15, 2011 at 12:45 AM, Richard Murphy
<[email protected]> wrote:
> Hi Nick ,
> I appreciate that it looks foolish making a wide dataset even wider,
> but I don't think its that bad in this case.
> I have university by degree level by year data. For each of these i
> have the number of students coming from 244 different countries, along
> with total EU and total OS.
>
> year    instit  LEVEL   os      uk      eu country1-country244
> 1994    1       ug              12      146     0
> 1994    1       pgr             3       335     3
> 1994    1       pgt     1       101     0
> 1995    1       ug              7       119     0
> 1995    1       pgr             4       300     9
> 1995    1       pgt             6       59      17
>
> There are 3 levels of degree, which i would like to make wide. So that
> I would have a panel dataset for universities over time. The reason
> why i want to do this is that I want to calculate the cross
> subsidisation that occurs between the degree levels, and for this I
> need the totals for each within an observation.
>
> I need to do this for all the countries as i'm using a Card
> Shift-Share approach as an instrument for changes in overseas numbers,
> which i would like to define in various different ways throughout the
> analysis (EU, NonEU, Asia, ect).
>
> And i would like the prefix, so that the variable names fit into my
> pre existing do files for the analysis.
>
> Best regards
> Richard
>
>
> On 14 March 2011 17:24, Nick Cox <[email protected]> wrote:
>> Please tell us directly more about your dataset and why you think
>> -reshape wide- is a good idea. From what you say it just make most
>> analyses more difficult. Also, how many variables will you end up
>> with?
>>
>> Nick
>>
>> On Tue, Mar 15, 2011 at 12:13 AM, Richard Murphy
>> <[email protected]> wrote:
>>> Hi all,
>>> I want to reshape long data to wide, putting the 'j' string variable
>>> at the begging of the stub.
>>> This would be fine if I have a limited number of variables as i can
>>> just use the @ function.
>>> reshape wide @var1 @var2 @var3 @var4, i(instit year) j(LEVEL) string
>>>
>>> But this does not work if i use the variable list functionality of
>>> reshape. I would like to know if their is an easier way of doing this,
>>> rather than typing in all 244 variables preceded by @.
>>> reshape wide @var1-@var244, i(instit year) j(LEVEL) string
>>>

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