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
How to construct a new variable by singling out one or more words from a longer phrase?I want to have a new variable which is constructed by taking out one or more words after "Battle of …
Needed new variable which should list duplicates with respect to industry codes and restarts as the industry code changes Hello Respected Experts, Thanks a lot for previous help. @Carlo Lazzaro, sir you provided a Stata …
one sided test of proportions using svyI am trying to do a one sided test of proportions with survey data. I've svyset the data. Normally I…
Foreach loopHi all, I please have another question. So I have variables Revenue_GDP, Expenditure_GDP, Consumpt…
Statistical significance between two discrete variablesDear Stata users: I have a variable called delay which is the number of days that a firm waited to d…
Subscribe to:
Post Comments (Atom)
0 Response to Creating a local list from a variable
Post a Comment