This post was updated on .
to select case number 1-55 and 82-162 this would not work:
select if (($casenum ge 1 and $casenum le 55) or ($casenum ge 82 and $casenum le 162)) . -> the select command only accepts the first part and selects case numbers 1 - 55. Is there any other way with select and several conditions ? ***************************************** This would work, but looks a bit clumsy. input program. loop a =1 to 200 by 1. end case. end loop. end file. end input program. exe. IF ($casenum ge 1 and $casenum le 55) group = 1. IF ($casenum ge 82 and $casenum le 162) group = 1. EXECUTE. SELECT IF group EQ 1. EXECUTE. select if (($casenum ge 1 and $casenum le 55) or ($casenum ge 82 and $casenum le 162)) . EXECUTE.
Dr. Frank Gaeth
|
The following works for me.
new file. input program. loop a =1 to 200 by 1. end case. end loop. end file. end input program. exe. IF ($casenum ge 1 and $casenum le 55) group = 1. freq var=group. IF ($casenum ge 82 and $casenum le 162) group = 1. freq var=group. temp. select if (($casenum ge 1 and $casenum le 55) or ($casenum ge 82 and $casenum le 162)) . freq var=group. NOTE: I use freq because I want to make sure of how many values I have. With Temp selection, you get N=136 but without it you get 55, that is, only the first part of select if operates. -Mike Palij New York University [hidden email] ----- Original Message ----- From: "drfg2008" <[hidden email]> To: <[hidden email]> Sent: Friday, February 13, 2015 8:59 AM Subject: select > to select case number 1-55 and 82-162 this would not work: > > select if (($casenum ge 1 and $casenum le 55) or ($casenum ge 82 and > $casenum le 162)) . > > -> the select command only accepts the first part > > > > > > input program. > loop a =1 to 200 by 1. > end case. > end loop. > end file. > end input program. > exe. > > > IF ($casenum ge 1 and $casenum le 55) group = 1. > IF ($casenum ge 82 and $casenum le 162) group = 1. > EXECUTE. > SELECT IF group EQ 1. > EXECUTE. > > select if (($casenum ge 1 and $casenum le 55) or ($casenum ge 82 and > $casenum le 162)) . > EXECUTE. > > > > > ----- > Dr. Frank Gaeth > > > -- > View this message in context: > http://spssx-discussion.1045642.n5.nabble.com/select-tp5728676.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
|
In reply to this post by drfg2008
Try this:
COMPUTE case = $casenum. SELECT IF RANGE(case,1,55,82,162).
--
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/). |
I would suggest to add EXECUTE before SELECT IF. Otherwise it also wouldn't work, as the selection had been made before evaluation of variable case. One need to be careful, joining $casenum and SELECT in a single data pass: 1. select if (($casenum ge 1 and $casenum le 55) or ($casenum ge 82 and $casenum le 162)) . In this instruction the first 55 cases will be selected, but on the 56th case condition will fail, the case will be dropped, and the next case's $casenum will be re-initialized as 56th. So, the $casenum will never reach 82. 2. temp. select if (($casenum ge 1 and $casenum le 55) or ($casenum ge 82 and $casenum le 162)) . Nice! But (IMHO) a bit tricky. This works (I guess) because SELECT IF under TEMP does not clears cases from the dataset but rather mask unselected cases upon the data pass. This option is, possibly, most safe (first, remember in a 'real' variable case number, and then - select): COMPUTE case = $casenum. EXECUTE. SELECT IF RANGE(case,1,55,82,162). DESCR case. Regards, Anton 13.02.2015, 18:24, "Bruce Weaver" <[hidden email]>: ===================== 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 |
Remember the USE command, where you can
just specify case number ranges.
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 ===================== 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
|
In reply to this post by Anton Balabanov-2
Good catch, Anton. You're right--without that EXECUTE, I'm left with only 55 cases, not 136. I should have tested before posting.
Cheers, Bruce
--
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
|
In reply to this post by Jon K Peck
Jon, if the FM has an example of USE selecting multiple ranges of case numbers, I can't find it. Can you give an example? Thanks.
--
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/). |
Sorry! I had in mind that we had
supported multiple ranges in USE, but I see that that never happened.
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Bruce Weaver <[hidden email]> To: [hidden email] Date: 02/13/2015 09:46 AM Subject: Re: [SPSSX-L] select Sent by: "SPSSX(r) Discussion" <[hidden email]> Jon, if the FM has an example of USE selecting multiple ranges of case numbers, I can't find it. Can you give an example? Thanks. Jon K Peck wrote > Remember the USE command, where you can just specify case number ranges. > > > Jon Peck (no "h") aka Kim > Senior Software Engineer, IBM > peck@.ibm > phone: 720-342-5621 > > ===================== > 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-tp5728676p5728691.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
|
No worries--thanks Jon.
And Happy National Ferris Wheel Day (among other things) to everyone tomorrow. ;-) http://www.npr.org/2015/02/13/385948445/not-in-the-mood-for-cupid-there-are-alternatives-to-valentines-day
--
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/). |
Free forum by Nabble | Edit this page |