Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

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

# Re: st: loop

 From Chiara Mussida To statalist@hsphsun2.harvard.edu Subject Re: st: loop Date Mon, 27 Aug 2012 11:33:27 +0200

```the suggestion of Nick works in the correct direction, and for sure I
do not need dummies for my cat.
Only two issues: i would need a weighted values of my cat before
computing the log. Second and related to this latter: is there a way
to compute log and not ln. I tried to write log instead of ln, but
Stata returns ln.
Thanks

On 27/08/2012, Nick Cox <njcoxstata@gmail.com> wrote:
> It's not possible to comment on Chiara's code or what went wrong
> because contrary to much repeated advice there are no precise details
> of what she tried.
>
> But given say -newcat121-newcat1212- the log of the frequencies of 1s
> are given by
>
> forval j = 1/12 {
>         su newcat12'j',  meanonly
>         .... = ln(r(sum))
> }
>
> where ... is the assignment to scalar or variable Chiara wants.
>
> But the dummies (indicators) are not necessary for this purpose at
> all. A -tabulate- of the original variable shows the frequencies in
> question.
>
> (For ' read left single quote above when appropriate.)
>
> Nick
>
> On 27 Aug 2012, at 08:22, Muhammad Anees <anees@aneconomist.com> wrote:
>
>> tab cat12, gen(newcat12)
>>
>> will give you those required variables (categorical or dummies).
>>
>> HTH
>> Anees
>>
>> On Mon, Aug 27, 2012 at 11:32 AM, Chiara Mussida
>> <cmussida@gmail.com> wrote:
>>> Dear all,
>>> the variable cat12 takes the values from 1 to 12. I want to create 12
>>> different scalars or variables for each cat. The problem is that each
>>> scalar must take the values correspondent to the log of the number of
>>> obs in each cat (weighted) since i have to write an index which needs
>>> those numbers. I tried with forvalues but i did not succeed!
>>> Ps: cat12 is a variable for occupational categories (from 1 to 12).
>>> In
>>> the index i put the weighted values (weight available in my dataset).
>>>
> *
> *   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/
>

--
Chiara Mussida
PhD candidate
Doctoral school of Economic Policy
Catholic University, Piacenza (Italy)
*
*   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/
```

• Follow-Ups:
• References:
• st: loop
• From: Chiara Mussida <cmussida@gmail.com>
• Re: st: loop
• From: Muhammad Anees <anees@aneconomist.com>
• Re: st: loop
• From: Nick Cox <njcoxstata@gmail.com>

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index