I have the following string values for two variables. I would like to create a local list from Var1 and/or Var2.
clear
input str4 Var1 str3 Var2
"A f" "H O"
"B" "L"
"C" "Z"
"D" "N t"
"E g" "m o"
"F" "a p"
"G" "w"
"" "q"
"" "po"
end
[/CODE]
when I use levels of this is what I get:
levelsof Var1, local(levels)
`"A f"' `"B"' `"C"' `"D"' `"E g"' `"F"' `"G"'
local List1 I desire is:
`" "A f" "B" "C" "D" "E g" "F" "G" "'
Similarly,
levelsof Var2, local(levels) is:
`"H O"' `"L"' `"N t"' `"Z"' `"a p"' `"m o"' `"po"' `"q"' `"w"'
local List2 I desire is:
`" "H O" "L" "N t" "Z" "a p" "m o" "po" "q" "w" "'
The goal is to eliminate manual entry to create List1 and and List2. Instead just grab them from the Var1 or Var2 and create a local list.
Any help would be appreciated.
Thanks
Related Posts with Creating a local list from a variable
"type mismatch" in collapseDear all, I'm getting the error message Code: type mismatch (r109) using the collapse function Co…
String HandlingHow do I remove trailing spaces for all variables in Stata at once? I know that I can remove spaces …
not losing data when collapsing on spellidI have a situation where I have 5 million records, many of them duplicates spellid's with separate p…
Error "svy not recognised"I am working with DHS data and I did the following gen weight = v005 / 1000000 clonevar psu_id = v0…
specification test for panel dataHello community after regressing my three models (FE,RE,Poold) I know that I have to choose between …
Subscribe to:
Post Comments (Atom)
0 Response to Creating a local list from a variable
Post a Comment