I have a variable which is string. i have certain set of values for
that string such as one set starting with GR,another with PG,yet
another with STU etc.Actually i have to select cases which are
starting with STU for analysis.I tried a lot. How can i select those
cases with "SELECT CASES"?
Please someone give me a suggestion.
The clearest way is to use the substring function to compute
a new variable that is the first three characters of the string.
Then use Filter or Select If to pick your cases.
--
Rich Ulrich
Select if substring(variable,1,3)='STU'.
Select if substring(variable,1,2)='GR'.
Select if substring(variable,1,2)='PG'
The first number in the substring is the starting character, and the
second number refers to the number of characters from the starting
character to include.
But note that SELECT IF deletes the unselected cases (from the working data file, i.e., not from the file stored on disk--unless you save over it). If you want to do that, fine. But if you want to temporarily exclude the unselected cases by setting a filter, then you would do something like:
compute STU = substring(variable,1,3)='STU'.
compute GR = substring(variable,1,2)='GR'.
compute PG = substring(variable,1,2)='PG'
use all.
filter by STU.
* Analyze the STU cases.
* When finished, turn off the filter.
use all.
filter off.