Hi there,
I'm wondering if there is a way either through syntax or the GUI to "select if" based on a range of cases within a variable. For example, the variable I'm working with is "Score", which range from 1-100, and I would like to delete cases if a score is between 25 and 43 by pointing to those cases within that variable. Any help would be greatly appreciated, thanks! |
Answers on the IBM site.
On Friday, October 14, 2016, Darko_Giac <[hidden email]> wrote: Hi there, -- ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
To identify the cases, and assuming cases have a serial number (caseid): temp. select if (score ge 25 and le 43). list caseid. . . and at your own risk! select if (score lt 25 and gt 43). John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jon Peck Answers on the IBM site.
Jon K Peck
|
Administrator
|
John, did you test that? I don't think it will work without the variable name being repeated when testing the LE 43 condition. I.e., I think you need this:
SELECT IF (score GE 25 AND score LE 43). But you could do the same thing more neatly (I think) with the RANGE function: SELECT IF RANGE(score,25,43).
--
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/). |
Administrator
|
I think you need a NOT. Filter might be a better approach? COMPUTE @Filter=NOT(RANGE(score,25,43)). FILTER BY @Filter. <Whatever the #$%% you need to do>. FILTER OFF. ______________________________________________________
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by Bruce Weaver
Bruce
You're right: the varname has to be repeated. TEMPORARY. select if (age ge30 and le 50). >Error # 4007 in column 16. Text: ge30 >The expression is incomplete. Check for missing operands, invalid operators, >unmatched parentheses or excessive string length. >Execution of this command stops. temp. select if (age ge 30 and age le 50). . . works. John -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver Sent: 15 October 2016 14:04 To: [hidden email] Subject: Re: Select If based on Case Range John, did you test that? I don't think it will work without the variable name being repeated when testing the LE 43 condition. I.e., I think you need this: SELECT IF (score GE 25 AND score LE 43). But you could do the same thing more neatly (I think) with the RANGE function: SELECT IF RANGE(score,25,43). John F Hall wrote > To identify the cases, and assuming cases have a serial number (caseid): > > temp. > select if (score ge 25 and le 43). > list caseid. > > . . and at your own risk! > > select if (score lt 25 and gt 43). > > John F Hall (Mr) > [Retired academic survey researcher] > > Email: > johnfhall@ > <mailto: > johnfhall@ > > > Website: www.surveyresearch.weebly.com > <http://www.surveyresearch.weebly.com/> > SPSS start page: > www.surveyresearch.weebly.com/1-survey-analysis-workshop > <http://surveyresearch.weebly.com/1-survey-analysis-workshop.html&g > t; > > > > From: SPSSX(r) Discussion [mailto: > SPSSX-L@.UGA > ] On Behalf Of Jon Peck > Sent: 14 October 2016 23:54 > To: > SPSSX-L@.UGA > Subject: Re: Select If based on Case Range > > Answers on the IBM site. > > On Friday, October 14, 2016, Darko_Giac < > darko.giacomini@ > <mailto: > darko.giacomini@ > > > wrote: > Hi there, > > I'm wondering if there is a way either through syntax or the GUI to > "select if" based on a range of cases within a variable. For example, > the variable I'm working with is "Score", which range from 1-100, and > I would like to delete cases if a score is between 25 and 43 by > pointing to those cases within that variable. > > Any help would be greatly appreciated, thanks! > > > > > > -- > View this message in context: > > Range-tp5733261.html Sent from the SPSSX Discussion mailing list > archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > <javascript:;> (not to SPSSX-L), with no body text except the > command. To leave the list, send the command SIGNOFF SPSSX-L For a > list of commands to manage subscriptions, send the command INFO > REFCARD > > > -- > Jon K Peck > jkpeck@ > <mailto: > jkpeck@ > > > > ===================== To manage your subscription to SPSSX-L, send a > message to > LISTSERV@.UGA > <mailto: > LISTSERV@.UGA > > (not to SPSSX-L), with no body text except the command. To leave > the list, send the command SIGNOFF SPSSX-L For a list of commands to > manage subscriptions, send the command INFO REFCARD > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (not to SPSSX-L), with no body text except the command. To leave the > list, send the command SIGNOFF SPSSX-L For a list of commands to > manage subscriptions, send the command INFO REFCARD ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Select-If-based-on-Case- Range-tp5733261p5733265.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
In reply to this post by Darko_Giac
I tested; you need an OR;
data list free/score. begin data 3 4 8 9 12 22 25 27 33 38 41 48 50 55 end data list score. select if score < 25 OR score>43. list score. bob k. -----Original Message----- From: Bruce Weaver [mailto:[hidden email]] Sent: Saturday, October 15, 2016 8:04 AM Subject: Re: Select If based on Case Range John, did you test that? I don't think it will work without the variable name being repeated when testing the LE 43 condition. I.e., I think you need this: SELECT IF (score GE 25 AND score LE 43). But you could do the same thing more neatly (I think) with the RANGE function: SELECT IF RANGE(score,25,43). John F Hall wrote > To identify the cases, and assuming cases have a serial number (caseid): > > temp. > select if (score ge 25 and le 43). > list caseid. > > . . and at your own risk! > > select if (score lt 25 and gt 43). > > John F Hall (Mr) > [Retired academic survey researcher] > > Email: > johnfhall@ > <mailto: > johnfhall@ > > > Website: www.surveyresearch.weebly.com > <http://www.surveyresearch.weebly.com/> > SPSS start page: > www.surveyresearch.weebly.com/1-survey-analysis-workshop > <http://surveyresearch.weebly.com/1-survey-analysis-workshop.html&g > t; > > > > From: SPSSX(r) Discussion [mailto: > SPSSX-L@.UGA > ] On Behalf Of Jon Peck > Sent: 14 October 2016 23:54 > To: > SPSSX-L@.UGA > Subject: Re: Select If based on Case Range > > Answers on the IBM site. > > On Friday, October 14, 2016, Darko_Giac < > darko.giacomini@ > <mailto: > darko.giacomini@ > > > wrote: > Hi there, > > I'm wondering if there is a way either through syntax or the GUI to > "select if" based on a range of cases within a variable. For example, > the variable I'm working with is "Score", which range from 1-100, and > I would like to delete cases if a score is between 25 and 43 by > pointing to those cases within that variable. > > Any help would be greatly appreciated, thanks! > > > > > > -- > View this message in context: > http://spssx-discussion.1045642.n5.nabble.com/Select-If-based-on-Case- > Range-tp5733261.html Sent from the SPSSX Discussion mailing list > archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > <javascript:;> (not to SPSSX-L), with no body text except the > command. To leave the list, send the command SIGNOFF SPSSX-L For a > list of commands to manage subscriptions, send the command INFO > REFCARD > > > -- > Jon K Peck > jkpeck@ > <mailto: > jkpeck@ > > > > ===================== To manage your subscription to SPSSX-L, send a > message to > LISTSERV@.UGA > <mailto: > LISTSERV@.UGA > > (not to SPSSX-L), with no body text except the command. To leave > the list, send the command SIGNOFF SPSSX-L For a list of commands to > manage subscriptions, send the command INFO REFCARD > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (not to SPSSX-L), with no body text except the command. To leave the > list, send the command SIGNOFF SPSSX-L For a list of commands to > manage subscriptions, send the command INFO REFCARD ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Select-If-based-on-Case-Range-tp5733261p5733265.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
Fair point, Robert: The OP wanted to "delete cases if a score is between 25 and 43", but somewhere along the line, that got turned around. One could still use the RANGE function, though.
SELECT IF NOT RANGE(score,25,34).
--
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/). |
Unless there's a backup data set I'd still use TEMP. first time
round: seen too many disasters. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver Sent: 16 October 2016 22:10 To: [hidden email] Subject: Re: Select If based on Case Range Fair point, Robert: The OP wanted to "delete cases if a score is between 25 and 43", but somewhere along the line, that got turned around. One could still use the RANGE function, though. SELECT IF NOT RANGE(score,25,34). Keefer, Robert P. wrote > I tested; you need an OR; > > data list free/score. > begin data > 3 4 8 9 12 22 25 27 33 > 38 41 48 50 55 > end data > list score. > select if score < 25 OR score>43. > list score. > > > bob k. > > > -----Original Message----- > From: Bruce Weaver [mailto: > bruce.weaver@ > ] > Sent: Saturday, October 15, 2016 8:04 AM > Subject: Re: Select If based on Case Range > > John, did you test that? I don't think it will work without the > variable name being repeated when testing the LE 43 condition. I.e., > I think you need this: > > SELECT IF (score GE 25 AND score LE 43). > > But you could do the same thing more neatly (I think) with the RANGE > function: > > SELECT IF RANGE(score,25,43). > > > > John F Hall wrote >> To identify the cases, and assuming cases have a serial number >> >> temp. >> select if (score ge 25 and le 43). >> list caseid. >> >> . . and at your own risk! >> >> select if (score lt 25 and gt 43). >> >> John F Hall (Mr) >> [Retired academic survey researcher] >> >> Email: > >> johnfhall@ > >> <mailto: > >> johnfhall@ > >> > >> Website: www.surveyresearch.weebly.com >> <http://www.surveyresearch.weebly.com/> >> SPSS start page: >> www.surveyresearch.weebly.com/1-survey-analysis-workshop >> >> g >> t; >> >> >> >> From: SPSSX(r) Discussion [mailto: > >> SPSSX-L@.UGA > >> ] On Behalf Of Jon Peck >> Sent: 14 October 2016 23:54 >> To: > >> SPSSX-L@.UGA > >> Subject: Re: Select If based on Case Range >> >> Answers on the IBM site. >> >> On Friday, October 14, 2016, Darko_Giac < > >> darko.giacomini@ > >> <mailto: > >> darko.giacomini@ > >> > > wrote: >> Hi there, >> >> I'm wondering if there is a way either through syntax or the GUI to >> "select if" based on a range of cases within a variable. For example, >> the variable I'm working with is "Score", which range from 1-100, and >> I would like to delete cases if a score is between 25 and 43 by >> pointing to those cases within that variable. >> >> Any help would be greatly appreciated, thanks! >> >> >> >> >> >> -- >> View this message in context: >> >> - Range-tp5733261.html Sent from the SPSSX Discussion mailing list >> archive at Nabble.com. >> >> ===================== >> To manage your subscription to SPSSX-L, send a message to > >> LISTSERV@.UGA > >> <javascript:;> (not to SPSSX-L), with no body text except the >> command. To leave the list, send the command SIGNOFF SPSSX-L For a >> list of commands to manage subscriptions, send the command INFO >> REFCARD >> >> >> -- >> Jon K Peck > >> jkpeck@ > >> <mailto: > >> jkpeck@ > >> > >> >> ===================== To manage your subscription to SPSSX-L, send >> message to > >> LISTSERV@.UGA > >> <mailto: > >> LISTSERV@.UGA > >> > (not to SPSSX-L), with no body text except the command. To >> leave the list, send the command SIGNOFF SPSSX-L For a list of >> commands to manage subscriptions, send the command INFO REFCARD >> >> ===================== >> To manage your subscription to SPSSX-L, send a message to > >> LISTSERV@.UGA > >> (not to SPSSX-L), with no body text except the command. To leave >> list, send the command SIGNOFF SPSSX-L For a list of commands to >> manage subscriptions, send the command INFO REFCARD > > > > > > ----- > -- > Bruce Weaver > bweaver@ > http://sites.google.com/a/lakeheadu.ca/bweaver/ > > "When all else fails, RTFM." > > NOTE: My Hotmail account is not monitored regularly. > To send me an e-mail, please use the address shown above. > > -- > View this message in context: > > Range-tp5733261p5733265.html Sent from the SPSSX Discussion mailing > list archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (not to SPSSX-L), with no body text except the command. To leave the > list, send the command SIGNOFF SPSSX-L For a list of commands to > manage subscriptions, send the command INFO REFCARD > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (not to SPSSX-L), with no body text except the command. To leave the > list, send the command SIGNOFF SPSSX-L For a list of commands to > manage subscriptions, send the command INFO REFCARD ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Select-If-based-on-Case- Range-tp5733261p5733272.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
In reply to this post by David Marso
Perfect. Thanks so much guys. This helped quite a bit!
|
Free forum by Nabble | Edit this page |