Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Selecting cases form string variable

8,035 views
Skip to first unread message

amrita gs

unread,
Jul 12, 2011, 1:32:42 AM7/12/11
to
Hi,

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.

Rich Ulrich

unread,
Jul 12, 2011, 1:58:38 AM7/12/11
to

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

Ammu

unread,
Jul 12, 2011, 3:00:30 AM7/12/11
to
Please give me an example......

fred....@lsc.gov.uk

unread,
Jul 12, 2011, 3:36:16 AM7/12/11
to
On Jul 12, 8:00 am, Ammu <amritha...@gmail.com> wrote:
> Please give me an example......

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.

Bruce Weaver

unread,
Jul 12, 2011, 8:45:52 AM7/12/11
to
On Tuesday, 12 July 2011 03:36:16 UTC-4, fred....@lsc.gov.uk wrote:

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.

0 new messages