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]

Re: st: String Variable in Collapse Command.


From   Carlos Avellaneda Suárez <[email protected]>
To   [email protected]
Subject   Re: st: String Variable in Collapse Command.
Date   Fri, 10 Jan 2014 07:52:48 -0500

As David Radwin has already told you, it is imposible to calculate a
statistic of a string variable. With that in mind, you can't use the
variable name in that part of the command. Here is a simple example of
what you can do:
clear
input str1 country id year y x
a 1 1990 5 3
a 1 1991 4 7
a 1 1992 3 6
a 1 1993 10 8
b 2 1990 8 6
b 2 1991 5 4
b 2 1992 9 7
b 2 1993 11 11
c 3 1990 10 15
c 3 1991 9 8
c 3 1992 11 13
c 3 1993 12 17
end
list
collapse (mean) y x, by(country id)
list
scatter y x, mlabel(country)

Hope this helps.

Carlos

2014/1/9 Sadia Khalid <[email protected]>:
> Thanks
>
> Carlos Avellaneda Suárez for your reply. I am using the following command.
>
> collapse name y x ,by( id)
>
> where name is the string variable. I want to take the average values
> of Y and X. Plot a scatter diagram.
> and have to label points on scatter diagram with name values.
>
> I am getting type mismatch error.
>
> Regards
>
> Sadia 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/


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