language to filter

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

language to filter

Angie Carrico
Hello all, I hate to bother all of you gurus with a simple question, but I am getting frustrated so here goes:  I am a point and click person (I know, I know - I want to learn syntax...and I promise I will get on that) and I keep running into little issues when trying to do more complex filters on data.  I am a bit familiar with sql and when I try to filter based on certain responses in string variables, I always can't get to seem the SPSS equiv to sql right.  Right now I am trying to filter my data (using point and click) so that the grades "I", "W" and "CP" are NOT used.  I have tried variants of GRADE_CODE <> ["W" or "I" or "CP"] and not (GRADE_CODE = "W"or "I"or "CP").  I have also done work in the past when trying to combine the answers used for different variables and it is ALWAYS a struggle when I get a bit more complex than a simple AND or OR statement.  Not sure if it takes LIKE, etc.  I just can't it right.  I have looked under help.  I have googled.  But my key words aren't correct.  I don't feel like it is really "syntax" but I am not sure what else to call it. Can anyone provide guidance?  Where can I find the rules on writing more complex statements?

--
Angela Carrico
Director of Institutional Research
Southwestern Michigan College
58900 Cherry Grove Rd
Dowagiac MI 49047
1-800-456-8675, ext. 1323
Reply | Threaded
Open this post in threaded view
|

Re: language to filter

MaxJasper
Message
GRADE_CODE ~= mid-string(W_var, starting at char, #chars) &
GRADE_CODE ~= mid-string(I_var, start char, #chars) & ....
 
Find real string function names to extract "W", "I", "CP" into select cases based on  not W & not I & not CP
 
Alternatively, change categorical text variables W, I, CP into numeric categorical variables and get rid of string function.
-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Angie Carrico
Sent: Friday, November 19, 2010 18:22
To: [hidden email]
Subject: language to filter

Hello all, I hate to bother all of you gurus with a simple question, but I am getting frustrated so here goes:  I am a point and click person (I know, I know - I want to learn syntax...and I promise I will get on that) and I keep running into little issues when trying to do more complex filters on data.  I am a bit familiar with sql and when I try to filter based on certain responses in string variables, I always can't get to seem the SPSS equiv to sql right.  Right now I am trying to filter my data (using point and click) so that the grades "I", "W" and "CP" are NOT used.  I have tried variants of GRADE_CODE <> ["W" or "I" or "CP"] and not (GRADE_CODE = "W"or "I"or "CP").  I have also done work in the past when trying to combine the answers used for different variables and it is ALWAYS a struggle when I get a bit more complex than a simple AND or OR statement.  Not sure if it takes LIKE, etc.  I just can't it right.  I have looked under help.  I have googled.  But my key words aren't correct.  I don't feel like it is really "syntax" but I am not sure what else to call it. Can anyone provide guidance?  Where can I find the rules on writing more complex statements?

--
Angela Carrico
Director of Institutional Research
Southwestern Michigan College
58900 Cherry Grove Rd
Dowagiac MI 49047
1-800-456-8675, ext. 1323
Reply | Threaded
Open this post in threaded view
|

Re: language to filter

Bruce Weaver
Administrator
In reply to this post by Angie Carrico
Try this:

NOT ANY(GRADE_CODE, "W","I","CP")



Angie Carrico wrote
Hello all, I hate to bother all of you gurus with a simple question, but I
am getting frustrated so here goes:  I am a point and click person (I know,
I know - I want to learn syntax...and I promise I will get on that) and I
keep running into little issues when trying to do more complex filters
on data.  I am a bit familiar with sql and when I try to filter based
on certain responses in string variables, I always can't get to seem the
SPSS equiv to sql right.  Right now I am trying to filter my data (using
point and click) so that the grades "I", "W" and "CP" are NOT used.  I have
tried variants of GRADE_CODE <> ["W" or "I" or "CP"] and not (GRADE_CODE =
"W"or "I"or "CP").  I have also done work in the past when trying to combine
the answers used for different variables and it is ALWAYS a struggle when I
get a bit more complex than a simple AND or OR statement.  Not sure if it
takes LIKE, etc.  I just can't it right.  I have looked under help.  I have
googled.  But my key words aren't correct.  I don't feel like it is really
"syntax" but I am not sure what else to call it. Can anyone provide
guidance?  Where can I find the rules on writing more complex statements?

--
Angela Carrico
Director of Institutional Research
Southwestern Michigan College
58900 Cherry Grove Rd
Dowagiac MI 49047
1-800-456-8675, ext. 1323
--
Bruce Weaver
bweaver@lakeheadu.ca
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.
Reply | Threaded
Open this post in threaded view
|

AW: language to filter

Jara Kampmann-2
In reply to this post by Angie Carrico
Bruce solution is definitly the most elegant one.
So, just a small hint for your future work (though I cannot look up my suggestions right now):
I guess what went wrong in the syntax you have sent is that <> only works for numerical vars but not for string. Because what shall "smaller and bigger" mean when it comes to string variables. So if you want to express "not equal to" rather use ~= or != or ne.

Maybe you'll have a look into the SPSS help for the command FILTER (which I guess you already did) and for the explanations given to "logical expressions".

Hope my suggestions are not nonsense and help

Best Jara

Von meinem drahtlosen BlackBerry®-Handheld gesendet


From: Angie Carrico <[hidden email]>
Sender: "SPSSX(r) Discussion" <[hidden email]>
Date: Fri, 19 Nov 2010 20:22:19 -0500
ReplyTo: Angie Carrico <[hidden email]>
Subject: language to filter

Hello all, I hate to bother all of you gurus with a simple question, but I am getting frustrated so here goes:  I am a point and click person (I know, I know - I want to learn syntax...and I promise I will get on that) and I keep running into little issues when trying to do more complex filters on data.  I am a bit familiar with sql and when I try to filter based on certain responses in string variables, I always can't get to seem the SPSS equiv to sql right.  Right now I am trying to filter my data (using point and click) so that the grades "I", "W" and "CP" are NOT used.  I have tried variants of GRADE_CODE <> ["W" or "I" or "CP"] and not (GRADE_CODE = "W"or "I"or "CP").  I have also done work in the past when trying to combine the answers used for different variables and it is ALWAYS a struggle when I get a bit more complex than a simple AND or OR statement.  Not sure if it takes LIKE, etc.  I just can't it right.  I have looked under help.  I have googled.  But my key words aren't correct.  I don't feel like it is really "syntax" but I am not sure what else to call it. Can anyone provide guidance?  Where can I find the rules on writing more complex statements?

--
Angela Carrico
Director of Institutional Research
Southwestern Michigan College
58900 Cherry Grove Rd
Dowagiac MI 49047
1-800-456-8675, ext. 1323
Reply | Threaded
Open this post in threaded view
|

Re: language to filter

John F Hall
In reply to this post by Angie Carrico
Angie
 
If you're a point-and-click addict and (by definition) almost allergic to syntax, check out these books:
 
Jacqueline Collier Using SPSS Syntax: A Beginner's Guide (Sage 2010)
is really a handbook for people already familiar with the drop-down menus, but attempting to wean them over to syntax, which is far easier and quicker to use and has more facilities than those available via the menus.  It's the only one to deal with dates.

Sarah Boslaugh An intermediate guide to SPSS programming: using syntax for data management (Sage 2005)
 

After all the other SPSS books I'm reviewing, it's like a breath of fresh air: clear and concise, nicely written and presented, and I finished it in two sittings (in preference to John Le Carré!).    It's absolutely wonderful: I have always been considered (by others) an expert in SPSS, having been a user, consultant and teacher since 1972, but I learned a few things from this book, some new, some better explained than in manuals or by the experts on the SPSSX-Listerver.  There's far more coverage than in other books and I particularly like the approach of posing data-management and research problems and situations before launching into SPSS syntax.  The author has clearly worked on dozens if not hundreds of different data sets for different clients and/or students and comes across as a rare kindred spirit.

The book is based on SPSS 11 so some of her syntax examples are by now rather dated, and SPSS has largely superceded them, but  her logic and method remain valid and relevant.  Has she thought about a new edition?  In private correspondence, she says yes, and with SPSS 18. preferably with much larger, and real, data sets: also, despite her reservations about different operational environments, some actual screenshots? 
 
Eric Einspruch Next Steps with SPSS (Sage 2004) is a bit heavy going, but OK if you're an experienced user of SPSS
    
You might also check out the extensive full colour step-by-step SPSS tutorials on my website.  They're unapologetically syntax-based, use real data from ractual surveys, and assume no prior knowledge or experience of SPSS or of data from questionnaire surveys (or any other source).  I'm currently in the middle of a major revision of tutorials for handling one variable, which should be uploaded and running by Monday, but the existing ones will see you OK for now, and there's plenty more to explore.
 

----- Original Message -----
Sent: Saturday, November 20, 2010 2:22 AM
Subject: language to filter

Hello all, I hate to bother all of you gurus with a simple question, but I am getting frustrated so here goes:  I am a point and click person (I know, I know - I want to learn syntax...and I promise I will get on that) and I keep running into little issues when trying to do more complex filters on data.  I am a bit familiar with sql and when I try to filter based on certain responses in string variables, I always can't get to seem the SPSS equiv to sql right.  Right now I am trying to filter my data (using point and click) so that the grades "I", "W" and "CP" are NOT used.  I have tried variants of GRADE_CODE <> ["W" or "I" or "CP"] and not (GRADE_CODE = "W"or "I"or "CP").  I have also done work in the past when trying to combine the answers used for different variables and it is ALWAYS a struggle when I get a bit more complex than a simple AND or OR statement.  Not sure if it takes LIKE, etc.  I just can't it right.  I have looked under help.  I have googled.  But my key words aren't correct.  I don't feel like it is really "syntax" but I am not sure what else to call it. Can anyone provide guidance?  Where can I find the rules on writing more complex statements?

--
Angela Carrico
Director of Institutional Research
Southwestern Michigan College
58900 Cherry Grove Rd
Dowagiac MI 49047
1-800-456-8675, ext. 1323
Reply | Threaded
Open this post in threaded view
|

Re: AW: language to filter

David Marso
Administrator
In reply to this post by Jara Kampmann-2
"I guess what went wrong in the syntax you have sent is that <> only works for numerical vars but not for string. Because what shall "smaller and bigger" mean when it comes to string variables. So if you want to express "not equal to" rather use ~= or != or ne. "..."Hope my suggestions are not nonsense and help"...

Jara,
 Not to be rude, but your suggestion is COMPLETE NONSENSE!!!
"Because what shall "smaller and bigger" mean"...
Look up the terms Collation? Alphabetization...?
a<>b!!!
<> is equivalent to NE , !=, ~=...
a < b < c < A < B ... < Z etc.
I guess?????? <> ANSWER!
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?"