Statalist


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

Re: st: RE: rowlast for string variables


From   Andrzej Niemierko <aniemierko@PARTNERS.ORG>
To   Stata <statalist@hsphsun2.harvard.edu>
Subject   Re: st: RE: rowlast for string variables
Date   Sat, 29 Aug 2009 11:51:33 -0400

egen rowlast_for_string = rowlast(a b)
causes "type mismatch" error message for a and b string variables while:
egen str rowlast_for_string = rowlast(a b)
works perfectly fine.

Andrzej


On 8/29/09 11:05 AM, "Nick Cox" <n.j.cox@durham.ac.uk> wrote:

> Inspection of the code shows that -egen, rowlast()- is indifferent to
> variable type in so far as
> 
> 1. The syntax specifies a varlist without restriction.
> 
> 2. The test for missingness uses -missing()- which applies to numeric
> and string variables alike.
> 
> -egen, rowlast()- is likely to fall over for a mix of numeric and string
> variables, an unlikely but not impossible request.
> 
> Nick 
> n.j.cox@durham.ac.uk
> 
> Andrzej Niemierko
> 
> Thank you very much Joseph! Indeed, it does work. Somehow I forgot to
> include type (str) in the command line.
> 
> On 8/29/09 4:50 AM, "Joseph Coveney" <jcoveney@bigplanet.com> wrote:
> 
>> -egen . . .,  rowlast(. . .)- works with string variables for me.
> What
>> problem
>> are you having?
>> 
>> Joseph Coveney
>> 
>> . clear *
>> 
>> . set obs 2
>> obs was 0, now 2
>> 
>> . generate str a = "A"
>> 
>> . generate str b = "B"
>> 
>> . replace a = "" in 1
>> (1 real change made)
>> 
>> . replace b = "" in 2
>> (1 real change made)
>> 
>> . egen str rowlast_for_string = rowlast(a b)
>> 
>> . list, noobs
>> 
>>   +------------------+
>>   | a   b   rowlas~g |
>>   |------------------|
>>   |     B          B |
>>   | A              A |
>>   +------------------+
> 
>> Andrzej Niemierko wrote:
>> 
>> Is there an equivalent of egen function "rowlast(varlist)" for string
>> variables?
>  
> 
> *
> *   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/



The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index