Hi,
may be you can help me :-) Is it possible to round a number to the nearest 0.5 er values? For example 3.26 should be 3.5 7.17 should be 7 7.6 should be 8 Is that possible? Thank you! -- Sent from: http://spssx-discussion.1045642.n5.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 |
Administrator
|
DATA LIST FREE / X.
BEGIN DATA 3.26 7.17 7.6 END DATA. COMPUTE y=RND(x*2)/2. LIST. 7.6 should be 7.5!! --- emma78 wrote > Hi, > may be you can help me :-) > > > Is it possible to round a number to the nearest 0.5 er values? > > For example > > 3.26 should be 3.5 > 7.17 should be 7 > 7.6 should be 8 > > > Is that possible? > Thank you! > > > > > -- > Sent from: http://spssx-discussion.1045642.n5.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 ----- 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?" -- Sent from: http://spssx-discussion.1045642.n5.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
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 emma78
COMPUTE Rounded = RND(Old,0.5).
----- Andy W [hidden email] http://andrewpwheeler.wordpress.com/ -- Sent from: http://spssx-discussion.1045642.n5.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 |
In reply to this post by emma78
compute z = rnd(2*z)/2. or, trickier, compute z = rnd(z, .5). On Thu, Oct 26, 2017 at 9:50 AM, emma78 <[hidden email]> wrote: Hi, |
Do not do this. Always keep it possible to go back and redraft your syntax
as the other responses to your post did. put the result in a new variable. compute newvar = rnd(2*z)/2. ----- Art Kendall Social Research Consultants -- Sent from: http://spssx-discussion.1045642.n5.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
Art Kendall
Social Research Consultants |
In reply to this post by emma78
Look at the rnd function in the syntax reference. I think you will find it inadequate for some of your examples and inadequate for others. I think you might be able to write a bit of syntax but I'm not sure. What I have in mind would exploit the difference between rnd(2*x) and 2*rnd(x).
3.26 should be 3.5 <<won't work. 7.17 should be 7 << will work. 7.6 should be 8 << will work. Gene Maguin -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of emma78 Sent: Thursday, October 26, 2017 11:51 AM To: [hidden email] Subject: Rounding Hi, may be you can help me :-) Is it possible to round a number to the nearest 0.5 er values? For example 3.26 should be 3.5 7.17 should be 7 7.6 should be 8 Is that possible? Thank you! -- Sent from: http://spssx-discussion.1045642.n5.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
|
BUT 8 is NOT closest to 7.6. 7.5 is the required result.
-- Maguin, Eugene wrote > Look at the rnd function in the syntax reference. I think you will find it > inadequate for some of your examples and inadequate for others. I think > you might be able to write a bit of syntax but I'm not sure. What I have > in mind would exploit the difference between rnd(2*x) and 2*rnd(x). > > 3.26 should be 3.5 <<won't work. > 7.17 should be 7 << will work. > 7.6 should be 8 << will work. > > Gene Maguin > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:<email>SPSSX-L@.UGA > ] On Behalf Of emma78 > Sent: Thursday, October 26, 2017 11:51 AM > To: > SPSSX-L@.UGA > Subject: Rounding > > Hi, > may be you can help me :-) > > > Is it possible to round a number to the nearest 0.5 er values? > > For example > > 3.26 should be 3.5 > 7.17 should be 7 > 7.6 should be 8 > > > Is that possible? > Thank you! > > > > > -- > Sent from: http://spssx-discussion.1045642.n5.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 ----- 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?" -- Sent from: http://spssx-discussion.1045642.n5.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
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?" |
Thank you all!
Yes I made a mistake with 7,6 this should be 7.5 you are right :-) -- Sent from: http://spssx-discussion.1045642.n5.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 |
Free forum by Nabble | Edit this page |