Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: RE: How to generate this variable please?


From   Nirina F <[email protected]>
To   [email protected]
Subject   Re: st: RE: RE: How to generate this variable please?
Date   Thu, 22 Oct 2009 08:00:41 -0400

Dear Martin,

Thank you very much for your response.
I think we can use this data as an example:

use http://fmwww.bc.edu/ec-p/data/hayashi/griliches76.dta

We can use "year"(though there are not that many years here but we can
see the average within -1 and +1 years (instead -3, +3).
then we can consider variable "tenure" to be like "field" in my case.

So now I would like to attribute for example to year 67  the average
tenure category 1  in percent during  the period of 66, 67, and 68.

Best regards,
Nirina




On Thu, Oct 22, 2009 at 4:02 AM, Martin Weiss <[email protected]> wrote:
>
> <>
> " Now I get confused also with the data you created."
>
>
> That was not my intention. It is always difficult to recreate a dataset from
> descriptions given on Statalist, so you may want to show an excerpt of your
> data. Sure, you cannot simply attach it, but you can use -input- to provide
> a meaningful chunk of your data....
>
>
>
> HTH
> Martin
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von Nirina F
> Gesendet: Donnerstag, 22. Oktober 2009 03:48
> An: [email protected]
> Betreff: Re: st: RE: RE: How to generate this variable please?
>
> Thank you very much Martin for your response. I might have not been
> clear. I am so  sorry.
> The mean that I would like to create is the mean of  frequency (in
> percentage actually not in absolute value) of just category 1 to start
> with.
> I am trying to find a data that could be used to make it easier
> because I cannot send files on this list. Now I get confused also with
> the data you created.
>
>
> On Wed, Oct 21, 2009 at 6:16 PM, Martin Weiss <[email protected]> wrote:
>>
>> <>
>>
>> The - forv y=1952/1998- should probably run as - forv y=1953/1997- for a
>> three year window so no window gets "chopped"...
>>
>>
>> HTH
>> Martin
>>
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of Martin Weiss
>> Sent: Mittwoch, 21. Oktober 2009 23:52
>> To: [email protected]
>> Subject: st: RE: How to generate this variable please?
>>
>>
>> <>
>>
>> Try this with no warranty :-)
>> I do have a feeling there is some command, like moving average or
> -rolling-,
>> that can make this a little more elegant...
>>
>> **
>> clear*
>> set obs 51
>>
>> gen year=_n+1949
>> expand 100
>>
>> gen byte category=irecode(runiform(), /*
>>  */ 0, .08, .16, .24, .32, .4, .48, /*
>>  */  .54, .62, .68, .78, .89 )
>>
>> compress
>>
>> capture erase info.dta
>> tempname hdle
>> postfile `hdle' year /*
>>  */ category mean /*
>>  */  using info
>>
>> levelsof category, local(mycats)
>>
>> qui forv y=1952/1998{
>>        foreach cat of local mycats{
>>                cou if inrange(year, `y'-3, `y'+3) & /*
>>                */ category==`cat'
>>                post `hdle' (`y') (`cat') (`r(N)')
>>                }
>>  }
>>
>> postclose `hdle'
>>
>> u info, clear
>> gen lb=y-3
>> gen ub=y+3
>> order lb year ub /*
>>  */  category mean
>>
>> l,  noobs sepby(year) h(30)
>>
>> **
>>
>>
>> HTH
>> Martin
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of Nirina F
>> Sent: Mittwoch, 21. Oktober 2009 23:05
>> To: [email protected]
>> Subject: st: How to generate this variable please?
>>
>> Dear all,
>>
>> I am not even sure how to search in the help for this so I thought I
>> would ask you.
>>
>> I have two variables year (1950 to 2000) and field. Field has
>> different categories 1 for accounting, 2 for art 3 for biochemistry
>> etc....until 12.
>>
>> I would like to have a variable that shows the mean of the frequency
>> in accounting (category 1) for year -3 and +3. To be more explicit:
>> for example, I studied in 1955. I would like to attribute to myself
>> the average frequency of people who did accounting between 1952 and
>> 1958 so that it will be an indicator for me on how popular accounting
>> was around 1955. For year 1950, we can just look at +3, for year 2000,
>> we can just look at -3 years.
>> I am confused myself so I hope you understand what I mean.
>> then I would like to do it for category 5 and 6 together of variable
> Field.
>>
>> Thank you so very much in advance for your help,
>> Nirina
>> *
>> *   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/
>>
>
> *
> *   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index