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]

st: Adding "if group==1" option to a short program -- or ",by(group)"


From   Marta García-Granero <[email protected]>
To   [email protected]
Subject   st: Adding "if group==1" option to a short program -- or ",by(group)"
Date   Tue, 02 Jul 2013 09:51:05 +0200

Good morning.

I have written this short program:

program skr2
version 12.1
args x
confirm variable `x'
 _pctile `x', nquantiles(8)
 local sk2=(r(r6)+r(r2)-2*r(r4))/(r(r6)-r(r2))
 local kr2=(r(r7)-r(r5)+r(r3)-r(r1))/(r(r6)-r(r2)) - 1.2333
 display "Bowley's skewness [-1; 1]:     " %6.2f `sk2'
 display "Moor's kurtosis [-1.23; inf.]: " %6.2f `kr2'
 end

As it can be seen from its contents, it computes robust skewness and kurtosis coefficients for just one variable.

I promise I have tried to read the documentation on programming, but I couldn't find how to modify it to be able to accept the selection of subgroups based on a second variable, like:

skr2 iron if group==1

or maybe

skr2 iron, by(group)

Any hints would be very much appreciated. I don't need the complete solution (I'd like to face the task and learn more about Stata programming), just a gentle push in the correct direction.

Thanks a lot,
Marta GG


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