Hello,
I would like to separate a string variable.
So far, the code I have been using is:
The variable in question - geoname - means something like "county name, state abbreviation." I would like to have one column with the county and one column with the state abbreviation. In some cases, however, there is a second county/independent city specified. How do I specify the parsing location so that I still end up with one column that contains just the state abbreviation and one that contains the full county/indep. city? I'd also like to get rid of the * where it exists, but that's just a secondary concern
Thank you!
I would like to separate a string variable.
So far, the code I have been using is:
Code:
split geoname, parse(,) generate(newgeo)
Thank you!
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str48 geoname str43 newgeo1 str30 newgeo2 str4 newgeo3 "Campbell + Lynchburg, VA*" "Campbell + Lynchburg" " VA*" "" "Campbell + Lynchburg, VA*" "Campbell + Lynchburg" " VA*" "" "Campbell + Lynchburg, VA*" "Campbell + Lynchburg" " VA*" "" "Carroll + Galax, VA*" "Carroll + Galax" " VA*" "" "Carroll + Galax, VA*" "Carroll + Galax" " VA*" "" "Carroll + Galax, VA*" "Carroll + Galax" " VA*" "" "Dinwiddie, Colonial Heights + Petersburg, VA*" "Dinwiddie" " Colonial Heights + Petersburg" " VA*" "Dinwiddie, Colonial Heights + Petersburg, VA*" "Dinwiddie" " Colonial Heights + Petersburg" " VA*" "Dinwiddie, Colonial Heights + Petersburg, VA*" "Dinwiddie" " Colonial Heights + Petersburg" " VA*" "Fairfax, Fairfax City + Falls Church, VA*" "Fairfax" " Fairfax City + Falls Church" " VA*" "Fairfax, Fairfax City + Falls Church, VA*" "Fairfax" " Fairfax City + Falls Church" " VA*" "Fairfax, Fairfax City + Falls Church, VA*" "Fairfax" " Fairfax City + Falls Church" " VA*" "Frederick + Winchester, VA*" "Frederick + Winchester" " VA*" "" "Frederick + Winchester, VA*" "Frederick + Winchester" " VA*" "" "Frederick + Winchester, VA*" "Frederick + Winchester" " VA*" "" "Greensville + Emporia, VA*" "Greensville + Emporia" " VA*" "" "Greensville + Emporia, VA*" "Greensville + Emporia" " VA*" "" "Greensville + Emporia, VA*" "Greensville + Emporia" " VA*" "" "Henry + Martinsville, VA*" "Henry + Martinsville" " VA*" "" "Henry + Martinsville, VA*" "Henry + Martinsville" " VA*" "" "Henry + Martinsville, VA*" "Henry + Martinsville" " VA*" "" "James City + Williamsburg, VA*" "James City + Williamsburg" " VA*" "" "James City + Williamsburg, VA*" "James City + Williamsburg" " VA*" "" "James City + Williamsburg, VA*" "James City + Williamsburg" " VA*" "" "Montgomery + Radford, VA*" "Montgomery + Radford" " VA*" "" "Montgomery + Radford, VA*" "Montgomery + Radford" " VA*" "" "Montgomery + Radford, VA*" "Montgomery + Radford" " VA*" "" "Pittsylvania + Danville, VA*" "Pittsylvania + Danville" " VA*" "" "Pittsylvania + Danville, VA*" "Pittsylvania + Danville" " VA*" "" "Pittsylvania + Danville, VA*" "Pittsylvania + Danville" " VA*" "" "Prince George + Hopewell, VA*" "Prince George + Hopewell" " VA*" "" "Prince George + Hopewell, VA*" "Prince George + Hopewell" " VA*" "" "Prince George + Hopewell, VA*" "Prince George + Hopewell" " VA*" "" "Prince William, Manassas + Manassas Park, VA*" "Prince William" " Manassas + Manassas Park" " VA*" "Prince William, Manassas + Manassas Park, VA*" "Prince William" " Manassas + Manassas Park" " VA*" "Prince William, Manassas + Manassas Park, VA*" "Prince William" " Manassas + Manassas Park" " VA*" "Roanoke + Salem, VA*" "Roanoke + Salem" " VA*" "" "Roanoke + Salem, VA*" "Roanoke + Salem" " VA*" "" "Roanoke + Salem, VA*" "Roanoke + Salem" " VA*" "" "Rockbridge, Buena Vista + Lexington, VA*" "Rockbridge" " Buena Vista + Lexington" " VA*" "Rockbridge, Buena Vista + Lexington, VA*" "Rockbridge" " Buena Vista + Lexington" " VA*" "Rockbridge, Buena Vista + Lexington, VA*" "Rockbridge" " Buena Vista + Lexington" " VA*" "Rockingham + Harrisonburg, VA*" "Rockingham + Harrisonburg" " VA*" "" "Rockingham + Harrisonburg, VA*" "Rockingham + Harrisonburg" " VA*" "" "Rockingham + Harrisonburg, VA*" "Rockingham + Harrisonburg" " VA*" "" end
Comment