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]
AW: st: Grouping variables
From
"Martin Weiss" <[email protected]>
To
<[email protected]>
Subject
AW: st: Grouping variables
Date
Fri, 5 Mar 2010 14:26:58 +0100
<>
"
gen province=a if (city=="b"|city=="c"|city=="d")
replace province=b if (city=="e"|city=="f"|city=="g")
"
Those province identifiers would have to carry quotation marks around them:
*************
clear*
inp str1 city
a
b
c
d
e
f
g
end
gen str1 province="a" if inlist(city, "b","c","d")
replace province="b" if inlist(city, "e","f","g")
list, noo
*************
Better still, assign numeric identifiers, and use a -value label- to
represent the strings...
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Katya Mauff
Gesendet: Freitag, 5. März 2010 14:00
An: [email protected]
Betreff: Re: st: Grouping variables
Dear Alejandra
Try using an if statement. So for example:
gen province=a if (city=="b"|city=="c"|city=="d")
replace province=b if (city=="e"|city=="f"|city=="g")
etc.
I know it's slightly tedious, esp if you have several cities/provinces.
Perhaps someone else can come up with a quicker way to do it.
>>> <[email protected]> 2010/03/05 02:47 PM >>>
Dear Statalits,
In my database I have a variable, called "city" which represent firms'
main base. It is a string variable that I've already encoded in an
another.
I have a lot of other information about the firms and I need to work at a
more aggregated level, for instance "province", could you please tell me
how to assign different cities to one province?
Thanks in advance.
Best regards,
Alejandra
*
* 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/
*
* 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/
*
* 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/