Philipp,
No, I don't get an error code. Instead, the var for egen
var=rowmin(varlist) is evaluated to zero or missing. In fact, some of
the rows have all zeroes; the rest contain some zeroes and a few values
between 1 and 13.
I first create a variable called "rowsum" that totals the row, then I
egen for the min value on the condition that the rowsum is not equal to
zero. Yet, the egen (rowmin) still evaluates to zeroes and missings.
All "seq*" variables are type byte, containing a value of 0 to 13.
Here's the code:
bys id: egen rowsum =
total(seq1+seq2+seq3+seq4+seq5+seq6+seq7+seq8+seq9+seq10+seq11+seq12+seq
13)
egen byte minmath = rowmin(mathseq*) if rowsum~=0
I had initially tried egen rowsum=total(seq1-seq13) but Stata
interpreted the dash as an operator (minus sign). So I tried using a
colon and received an "invalid name" error. Then I entered each
variable separated by a space, e.g. total(seq1 seq2 seq3 ...) and again
received an "invalid name" error, as though I had streamed all the
variables together without spaces. This is why I included the plus
signs.
Here's the result:
. tab minmath,m
minmath | Freq. Percent Cum.
----------+----------------------------------
0 | 19,380 99.38 99.38
. | 121 0.62 100.00
----------+----------------------------------
Total | 19,501 100.00
Any ideas?
Thanks,
Terri
Philipp Rehm wrote:
>Can you give an example? Is there an error-code? (For example, Are you
>sure you don't include, say, a string variable in the varlist?)
>
>The following seems to work:
>
>sysuse auto, clear
>egen min=rowmin(price weight turn)
>egen max=rowmax(price weight turn)
>
>list price weight turn min max
>
>HTH,
>Philipp
>
>Teresa Dale Nelson wrote:
>> Hello,
>> Does anyone know why egen's rowmax command would work but its rowmin
>> would not? My data have cases that should suffice in either case.
>> Thank you,
>> Terri
>> *
>> * For searches and help try:
>> * http://www.stata.com/support/faqs/res/findit.html
>> * http://www.stata.com/support/statalist/faq
>> * http://www.ats.ucla.edu/stat/stata/
>>
>>
>*
>* For searches and help try:
>* http://www.stata.com/support/faqs/res/findit.html
>* http://www.stata.com/support/statalist/faq
>* http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/