Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Sadia Khalid <sadiakhalid234@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: RE: String Variable in Collapse Command. |
Date | Thu, 9 Jan 2014 21:05:58 -0800 |
Thanks David Radwin getting type mismatch error in this command collapse (firstnm) string1 (mean) num2, by(num1) On 9 January 2014 13:24, Radwin, David <dradwin@rti.org> wrote: > -collapse- cannot calculate a statistic like mean or sd of a string > variable. Instead, you have to use first, last, firstnm, or lastnm > (which is fine if the string variable is constant within the group and > problematic otherwise). Here is a simple example where string1 is > constant within num1 : > > input str1 string1 num1 num2 > a 1 5 > a 1 3 > a 1 9 > b 2 0 > b 2 4 > b 2 3 > c 3 1 > c 3 9 > end > > list > > collapse (firstnm) string1 (mean) num2, by(num1) > > list > > > David > -- > David Radwin, Senior Research Associate > Education and Workforce Development > RTI International > 2150 Shattuck Ave. Suite 800, Berkeley, CA 94704 > Phone: 510-665-8274 > > www.rti.org/education > >> -----Original Message----- >> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner- >> statalist@hsphsun2.harvard.edu] On Behalf Of Sadia Khalid >> Sent: Thursday, January 09, 2014 12:44 PM >> To: statalist@hsphsun2.harvard.edu >> Subject: st: String Variable in Collapse Command. >> >> Hi >> >> How to handle string variable in collapse command. >> >> when i am using the string variable in collapse command . i am getting >> an error message. >> >> I have a panel data, i want to take the average of the country values >> and than i have to draw a scatter diagram, and have to label the >> observations with country name. >> >> but the string variable in the collapse command is giving an error >> message. >> >> Regards >> >> Ssdia Khalid > > > * > * 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/ * * 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/