Use the index function to find an occurrence of the string
college or university.
data list / name (a40).
begin data
California State University
University of California
Claremont McKenna College
St Mary's College of California
Western Institute for Social Research
end data.
compute type=0.
if (index(upcase(name),'COLLEGE') > 0) type=1.
if (index(upcase(name),'UNIVERSITY')>0) type=2.
value labels type 1 "College" 2
"University".
list.
This example uppercases the entire string so there are no
distinctions between University and UNIVERSITY. Note that this will fail with
things like UC Berkeley, and UCLA and will classify University College London
as a University. If I were you I would look at all type=0 instances to check
for things like that.
Please take a look at all the string functions in HELP.
From: Jims More
[mailto:[hidden email]]
Sent: Saturday, May 09, 2009 7:10 PM
To: [hidden email]; ViAnn Beadle
Subject: Re: From String to String
A
string variable has three to six words.. Actually such variable
is name of schools where the values has word university or
college. Some other values have no words like university or
college. From such string variable, I would like to create another
variable which classify whether a case is a university, college or niether a
university nor a college. Is this possible in SPSS?
Yes,
but you have to give us much more information such as the good examples of
the string’s contents.
Here is the example name_of_institution and
Type_of_Institution as variables where Type_of_ institutionl is the target
variable:
Name_of_institution
Type_of_Institution
California State
University
University
University of
California Universiy
Claremont McKenna College
College
St Mary's College of
California College
Western Institute for Social
Research neither
a university nor a college
The first two institutions are classified as university
because there is word "university" in the name. The next two
intitutions are classified as college because a word "college" is
there in its name. The last institution cannot be classified as a
university or a college, hence, neither a university nor a college.
Hope this information is enough.
From: ViAnn Beadle <[hidden email]>
Subject: Re: From String to String
To: [hidden email]
Received: Saturday, 9 May, 2009, 4:04 PM
Yes,
but you have to give us much more information such as the good examples of
the string’s contents.
From: SPSSX(r)
Discussion [mailto:[hidden email]] On Behalf Of Jims More
Sent: Saturday, May 09, 2009 9:36 AM
To: [hidden email]
Subject: From String to String
A string variable has three to six words.. Actually such
variable is name of schools where the values has word university or
college. Some other values have no words like university or
college. From such string variable, I would like to create
another variable which classify whether a case is a university, college or
niether a university nor a college. Is this possible in SPSS?
|
Chat right from
the comfort of your inbox. Show me how..
|
Chat
right from the comfort of your inbox. Show me how..