Manipulating Locals
Remove duplicates
Use the
list uniq
macro list functionalitylocal vars state county county loc nodups : list uniq vars
display `nodups' . state county
Add/Remove Elements
Removing elements of a local is easy.
Create a local (
minus
) with the elements you want to removelocal vars a b c local minus a
display `vars' . a b c
Use the macro list functionality:
list
with a minuslocal vars : list vars - minus
display `vars' . b c
Union and intersection
Another useful tool is taking the common and different elements between two locals
local x state county
local y county tract
- For unions use
|
(like in x “or” y)local union : list x | y
display `union' . state county tract
- For intersections use
&
(like in x “and” y)local intersection : list x & y
display `intersection' . county
Sorting
Sometimes we want to sort elements of a local
Use
sort
macro list functionalitylocal unordered b c a local ordered : list sort unordered
display `ordered' . a b c