I am trying to collapse three (ultimately more) variables on zip codes, state names, and Congressional districts from a survey data set. (I tried to upload the data set but was told that it was not a viable image??). Here are the variables and the first 5 lines of data:
. des lookupzip inputstate cdid115
storage display value
variable name type format label variable label
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lookupzip str5 %-9s Zip code used for CD mapping
inputstate double %10.0g inputstate
State of Residence
cdid115 str2 %-9s CD 115th Congress
and
. clist lookupzip inputstate cdid115 in 1/5
lookupzip inputstate cdid115
1. 77087 Texas 29
2. 45039 Ohio 1
3. 40222 Kentucky 3
4. 85018 Arizona 9
5. 16335 Pennsylvan 3
I converted lookupzip and cdid115 to numeric--and that worked fine, but when I collapsed the variables the state codes were all numeric and I got the message that inputstate had no value labels.
There must be a way to get this done, but I don't know it. If you want the data set, email me (euslaner@umd.edu) and I will send it to you. Many thanks,
Ric
Related Posts with Collapse using both string and alphanumeric
bysort year : egen x=count() / bysort year : egen x=mean()Hello Statalist colleagues, I hope you are all staying healthy. I had a question while struggling …
Using egen to create new treatment variableHi, I am looking at a study involving student performance and gender. Students are observed taking …
Panel Data ProbabilitiesHello, I have panel data looking like the following: Code: * Example generated by -dataex-. For m…
Staggered diff in diffHey everyone, I will be evaluation a policy consisting on granting property rights to communities, …
Refer to multiple variables in StataHi, My variables' names are something like var11, var11_oth, var12, var12_oth, var13, var13_oth.etc…
Subscribe to:
Post Comments (Atom)
0 Response to Collapse using both string and alphanumeric
Post a Comment