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: RE: String Variable in Collapse Command.


From   "Radwin, David" <[email protected]>
To   <[email protected]>
Subject   st: RE: String Variable in Collapse Command.
Date   Thu, 9 Jan 2014 16:24:04 -0500

-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: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Sadia Khalid
> Sent: Thursday, January 09, 2014 12:44 PM
> To: [email protected]
> 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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index