// collect the values
levelsof var1, locals(loc1)
levelsof var2, locals(loc2)
// stack the macros
// NOTICE: no "=" sign
local loc "`loc1' `loc2'"
// get rid of the duplicates
local loc : list uniq loc
For more see: -help extended_fcn- and especially -help macrolists-
Hope this helps,
Maarten
On Mon, Jan 21, 2013 at 3:02 PM, Roberto Liebscher
<roberto.liebscher@ku.de> wrote:
> I have two variables both containing string values. I would like to get all
> unique values (not the number of unique values) from these two variables
> jointly.
>
> For example if I enter
>
> levelsof var1, locals(loc1)
> levelsof var2, locals(loc2)
>
> I obtain all unique values of var1 and all unique values of var2. But at the
> end I would like to have one local containing only unique values in loc1 AND
> loc2.
>
> Is there anyone who can help me with this?
>
> Thanks!
>
> Roberto
>
> --
> Roberto Liebscher
> Catholic University of Eichstaett-Ingolstadt
> Department of Business Administration
> Chair of Banking and Finance
> Auf der Schanz 49
> D-85049 Ingolstadt
>
> *
> * 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/
--
---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany
http://www.maartenbuis.nl
---------------------------------
*
* 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/