Create dummy variable from text?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Create dummy variable from text?

SPSSnewb
One of my variables consists of a range of company names (i.e. Widget, Inc.) as well as university and college names (i.e. University of Georgia). I'd like to create a dummy variable that codes all cells containing the words "college" or "university" as 1 and codes all other cells as 0. How should I go about this process? Thanks in advance for your time!
Reply | Threaded
Open this post in threaded view
|

Re: Create dummy variable from text?

Bruce Weaver
Administrator
Suppose your variable is V, and the new variable is Flag.  Something like this ought to do it:

compute #U = char.index(UPCASE(V),"UNIVERSITY") GT 0.
compute #C = char.index(UPCASE(V),"COLLEGE") GT 0.
compute Flag = #U or #C.
formats Flag(f1).


SPSSnewb wrote
One of my variables consists of a range of company names (i.e. Widget, Inc.) as well as university and college names (i.e. University of Georgia). I'd like to create a dummy variable that codes all cells containing the words "college" or "university" as 1 and codes all other cells as 0. How should I go about this process? Thanks in advance for your time!
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).