I have a category in which the values are both whole and decimal. I would
like to filter out all decimal cases. How is the syntax written for this operation? Thanks ===================== 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
|
OK!
Back up and ask yourself *HOW* would you determine that something is what you call a 'decimal case'? If I understand your intent, one way would to test whether when truncated or rounded the value remains the same. i.e. -- data list free / a . begin data 1 2 1.3 4 2.1 4 5 end data. compute @filter=(a EQ TRUNC(a)). FILTER BY @filter. list.
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?" |
Hey David, this is very creative, if I understand what you did. So you looked to see if the actual value of variable a is equal to the truncated value of a. If the value is 2, it would truncate to 2, and thus would be equal (true). If the value is 2.1 and it truncates to 2, then 2.1 won't equal 2, and thus would be false, and not selected. This is great, I had a way more complicated way of doing this in which I was going to suggest converting to a string, separating at the decimal, and seeing if the value of the variable for right of the decimal is null or not, and filtering on that.
Matthew J Poes Research Data Specialist Center for Prevention Research and Development University of Illinois 510 Devonshire Dr. Champaign, IL 61820 Phone: 217-265-4576 email: [hidden email] -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: Tuesday, April 03, 2012 12:21 PM To: [hidden email] Subject: Re: Selecting Cases OK! Back up and ask yourself *HOW* would you determine that something is what you call a 'decimal case'? If I understand your intent, one way would to test whether when truncated or rounded the value remains the same. i.e. -- data list free / a . begin data 1 2 1.3 4 2.1 4 5 end data. compute @filter=(a EQ TRUNC(a)). FILTER BY @filter. list. Andee D wrote > > I have a category in which the values are both whole and decimal. I > would like to filter out all decimal cases. How is the syntax written > for this operation? > > Thanks > > ===================== > 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 > -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Selecting-Cases-tp5615799p5615879.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 Andee D
compute newvar= trunc(oldvar).
if newvar eq oldvar whole = 1. filter by whole. However, why are you doing this? Art Kendall Social Research Consultants On 4/3/2012 12:40 PM, Andee D wrote: ===================== 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 REFCARDI have a category in which the values are both whole and decimal. I would like to filter out all decimal cases. How is the syntax written for this operation? Thanks ===================== 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
Art Kendall
Social Research Consultants |
In reply to this post by Andee D
To clarify, the variable is numeric and has two decimal places. I would like
to select only those cases with .00 in the decimal. ===================== 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 Andee D
I am creating tables and do not need the subcategories (1.1-1.9) only the
major categories (1.0) to show. ===================== 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 |
If those are categories (e.g., subtypes) would you
want to
compute majorcat= trunc(oldvar). Art Kendall Social Research Consultants On 4/3/2012 2:18 PM, Andee D wrote: ===================== 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 REFCARDI am creating tables and do not need the subcategories (1.1-1.9) only the major categories (1.0) to show. ===================== 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
Art Kendall
Social Research Consultants |
Administrator
|
In reply to this post by Poes, Matthew Joseph-2
My first thought was to use MOD and rejected that due to my *mistaken* impression that it would at weird with decimals (I think of MOD as dealing with integer remainders ;-).
So there are 3 solutions that come to mind RND as well but that is just a version of TRUNC. compute @filter=(a EQ TRUNC(a)). compute @filter2=(MOD(a,1) EQ 0). compute @filter3=(MOD(a*10,10) EQ 0). A @FILTER @FILTER2 @FILTER3 1.00 1.00 1.00 1.00 2.00 1.00 1.00 1.00 1.30 .00 .00 .00 4.00 1.00 1.00 1.00 2.10 .00 .00 .00 4.00 1.00 1.00 1.00 5.00 1.00 1.00 1.00 Number of cases read: 7 Number of cases listed: 7
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?" |
Free forum by Nabble | Edit this page |