Dear Samuel,
to two decimal places means X.xx, to three means X.xxx, etc. Rounding is all to do with less than or greater than .5 (or .05 or .005 etc). So 24.635 rounds to 24.64, to two decimal places. There are no hard and fast rules about rounding (e.g. do you round up, or down). You basically need a policy document saying what rules you are following. HTH, Martin Holt ===================== 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 |
yes but can you do it using syntax. RND returns an integer and so does TRUNC and I don't want that. for instance I have a numeric variable populated by decimal numbers. it is in a format f12.5. I want it to be rounded to f12.2 through syntax.
thanks, Samuel ________________________________ From: SPSSX(r) Discussion on behalf of Martin P. Holt Sent: Mon 12/24/2007 2:40 PM To: [hidden email] Subject: Re: rounding and truncating Dear Samuel, to two decimal places means X.xx, to three means X.xxx, etc. Rounding is all to do with less than or greater than .5 (or .05 or .005 etc). So 24.635 rounds to 24.64, to two decimal places. There are no hard and fast rules about rounding (e.g. do you round up, or down). You basically need a policy document saying what rules you are following. HTH, Martin Holt ===================== 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 |
formats varname (F12.2).
________________________________ From: SPSSX(r) Discussion on behalf of Samuel Solomon Sent: Mon 12/24/2007 6:23 AM To: [hidden email] Subject: Re: rounding and truncating yes but can you do it using syntax. RND returns an integer and so does TRUNC and I don't want that. for instance I have a numeric variable populated by decimal numbers. it is in a format f12.5. I want it to be rounded to f12.2 through syntax. thanks, Samuel ________________________________ From: SPSSX(r) Discussion on behalf of Martin P. Holt Sent: Mon 12/24/2007 2:40 PM To: [hidden email] Subject: Re: rounding and truncating Dear Samuel, to two decimal places means X.xx, to three means X.xxx, etc. Rounding is all to do with less than or greater than .5 (or .05 or .005 etc). So 24.635 rounds to 24.64, to two decimal places. There are no hard and fast rules about rounding (e.g. do you round up, or down). You basically need a policy document saying what rules you are following. HTH, Martin Holt ===================== 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 ====================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 Samuel Solomon
If you just want the display to be rounded, you can set the variable format to F12.2 with the FORMAT command. If you want the actually value to be changed to the rounded value, the usual way is to multiply the number by the appropriate power of 10, round or truncate to an integer, and then divide by the same power.
HTH, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Samuel Solomon Sent: Monday, December 24, 2007 5:23 AM To: [hidden email] Subject: Re: [SPSSX-L] rounding and truncating yes but can you do it using syntax. RND returns an integer and so does TRUNC and I don't want that. for instance I have a numeric variable populated by decimal numbers. it is in a format f12.5. I want it to be rounded to f12.2 through syntax. thanks, Samuel ________________________________ From: SPSSX(r) Discussion on behalf of Martin P. Holt Sent: Mon 12/24/2007 2:40 PM To: [hidden email] Subject: Re: rounding and truncating Dear Samuel, to two decimal places means X.xx, to three means X.xxx, etc. Rounding is all to do with less than or greater than .5 (or .05 or .005 etc). So 24.635 rounds to 24.64, to two decimal places. There are no hard and fast rules about rounding (e.g. do you round up, or down). You basically need a policy document saying what rules you are following. HTH, Martin Holt ===================== 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 ===================== 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 |
Samuel,
Below is an example of Jon's second suggestion ("If you want the actually value to be changed to the rounded value, the usual way is to multiply the number by the appropriate power of 10, round or truncate to an integer, and then divide by the same power."). If you're only rounding & truncating one variable, the REPEAT syntax would be unnecessary. *** Writes test data . DATA LIST FREE /var001 (F8.3) var002 (F8.3) var003 (F8.3) . BEGIN DATA 1.011 1.011 1.011 1.016 1.016 1.016 11.011 11.011 11.011 11.016 11.016 11.016 111.011 111.011 111.011 111.016 111.016 111.016 END DATA . LIST . *** Uses REPEAT to round and truncate all variables . DO REPEAT a = var001 to var003 /b = rnd001 to rnd003 /c = new001 to new003 . + COMPUTE b = RND(a/.01) . + COMPUTE c = b*.01 . END REPEAT . Best, --Justin -- Justin Black Doctoral Student Industrial-Organizational Psychology Baruch College, CUNY On Dec 24, 2007 10:31 AM, Peck, Jon <[hidden email]> wrote: > If you just want the display to be rounded, you can set the variable > format to F12.2 with the FORMAT command. If you want the actually value > to be changed to the rounded value, the usual way is to multiply the number > by the appropriate power of 10, round or truncate to an integer, and then > divide by the same power. > > HTH, > Jon Peck > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Samuel Solomon > Sent: Monday, December 24, 2007 5:23 AM > To: [hidden email] > Subject: Re: [SPSSX-L] rounding and truncating > > yes but can you do it using syntax. RND returns an integer and so does > TRUNC and I don't want that. for instance I have a numeric variable > populated by decimal numbers. it is in a format f12.5. I want it to be > rounded to f12.2 through syntax. > thanks, > Samuel > > ________________________________ > > From: SPSSX(r) Discussion on behalf of Martin P. Holt > Sent: Mon 12/24/2007 2:40 PM > To: [hidden email] > Subject: Re: rounding and truncating > > > > Dear Samuel, > > to two decimal places means X.xx, to three means X.xxx, etc. > > Rounding is all to do with less than or greater than .5 (or .05 or .005 > etc). > > So 24.635 rounds to 24.64, to two decimal places. > > There are no hard and fast rules about rounding (e.g. do you round up, or > down). You basically need a policy document saying what rules you are > following. > > HTH, > > Martin Holt > > ===================== > 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 > > ===================== > 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 |
All this begs the question as to why anybody would to do this. IMHO,
discarding precision in this way doesn't seem to be useful unless this is an accounting application and the metric is dollars and cents. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Justin Black Sent: Monday, December 24, 2007 12:30 PM To: [hidden email] Subject: Re: rounding and truncating Samuel, Below is an example of Jon's second suggestion ("If you want the actually value to be changed to the rounded value, the usual way is to multiply the number by the appropriate power of 10, round or truncate to an integer, and then divide by the same power."). If you're only rounding & truncating one variable, the REPEAT syntax would be unnecessary. *** Writes test data . DATA LIST FREE /var001 (F8.3) var002 (F8.3) var003 (F8.3) . BEGIN DATA 1.011 1.011 1.011 1.016 1.016 1.016 11.011 11.011 11.011 11.016 11.016 11.016 111.011 111.011 111.011 111.016 111.016 111.016 END DATA . LIST . *** Uses REPEAT to round and truncate all variables . DO REPEAT a = var001 to var003 /b = rnd001 to rnd003 /c = new001 to new003 . + COMPUTE b = RND(a/.01) . + COMPUTE c = b*.01 . END REPEAT . Best, --Justin -- Justin Black Doctoral Student Industrial-Organizational Psychology Baruch College, CUNY On Dec 24, 2007 10:31 AM, Peck, Jon <[hidden email]> wrote: > If you just want the display to be rounded, you can set the variable > format to F12.2 with the FORMAT command. If you want the actually value > to be changed to the rounded value, the usual way is to multiply the number > by the appropriate power of 10, round or truncate to an integer, and then > divide by the same power. > > HTH, > Jon Peck > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Samuel Solomon > Sent: Monday, December 24, 2007 5:23 AM > To: [hidden email] > Subject: Re: [SPSSX-L] rounding and truncating > > yes but can you do it using syntax. RND returns an integer and so does > TRUNC and I don't want that. for instance I have a numeric variable > populated by decimal numbers. it is in a format f12.5. I want it to be > rounded to f12.2 through syntax. > thanks, > Samuel ===================== 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 |
Agreed, except there are at least two other applications - for presentation
purposes and quality control. I have rounded and truncated in the past for exporting data to Excel for delivery in a "report" format; and also to produce QC files that can be checked against reports generated from the same data but using a different medium (SQL, e.g.). --Justin On Dec 24, 2007 3:03 PM, ViAnn Beadle <[hidden email]> wrote: > All this begs the question as to why anybody would to do this. IMHO, > discarding precision in this way doesn't seem to be useful unless this is > an > accounting application and the metric is dollars and cents. > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Justin Black > Sent: Monday, December 24, 2007 12:30 PM > To: [hidden email] > Subject: Re: rounding and truncating > > Samuel, > > Below is an example of Jon's second suggestion ("If you want the actually > value to be changed to the rounded value, the usual way is to multiply the > number by the appropriate power of 10, round or truncate to an integer, > and > then divide by the same power."). If you're only rounding & truncating > one > variable, the REPEAT syntax would be unnecessary. > > *** Writes test data . > > DATA LIST FREE > /var001 (F8.3) var002 (F8.3) var003 (F8.3) . > BEGIN DATA > 1.011 1.011 1.011 > 1.016 1.016 1.016 > 11.011 11.011 11.011 > 11.016 11.016 11.016 > 111.011 111.011 111.011 > 111.016 111.016 111.016 > END DATA . > LIST . > > *** Uses REPEAT to round and truncate all variables . > > DO REPEAT a = var001 to var003 /b = rnd001 to rnd003 /c = new001 to new003 > . > + COMPUTE b = RND(a/.01) . > + COMPUTE c = b*.01 . > END REPEAT . > > > > Best, > > --Justin > > -- > Justin Black > Doctoral Student > Industrial-Organizational Psychology > Baruch College, CUNY > > > On Dec 24, 2007 10:31 AM, Peck, Jon <[hidden email]> wrote: > > > If you just want the display to be rounded, you can set the variable > > format to F12.2 with the FORMAT command. If you want the actually value > > to be changed to the rounded value, the usual way is to multiply the > number > > by the appropriate power of 10, round or truncate to an integer, and > then > > divide by the same power. > > > > HTH, > > Jon Peck > > > > -----Original Message----- > > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > > Samuel Solomon > > Sent: Monday, December 24, 2007 5:23 AM > > To: [hidden email] > > Subject: Re: [SPSSX-L] rounding and truncating > > > > yes but can you do it using syntax. RND returns an integer and so does > > TRUNC and I don't want that. for instance I have a numeric variable > > populated by decimal numbers. it is in a format f12.5. I want it to be > > rounded to f12.2 through syntax. > > thanks, > > Samuel > > ===================== > 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 |
Wouldn't just changing the print format meet these requirements?
-----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Justin Black Sent: Monday, December 24, 2007 1:28 PM To: [hidden email] Subject: Re: rounding and truncating Agreed, except there are at least two other applications - for presentation purposes and quality control. I have rounded and truncated in the past for exporting data to Excel for delivery in a "report" format; and also to produce QC files that can be checked against reports generated from the same data but using a different medium (SQL, e.g.). --Justin On Dec 24, 2007 3:03 PM, ViAnn Beadle <[hidden email]> wrote: > All this begs the question as to why anybody would to do this. IMHO, > discarding precision in this way doesn't seem to be useful unless this is > an > accounting application and the metric is dollars and cents. > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Justin Black > Sent: Monday, December 24, 2007 12:30 PM > To: [hidden email] > Subject: Re: rounding and truncating > > Samuel, > > Below is an example of Jon's second suggestion ("If you want the actually > value to be changed to the rounded value, the usual way is to multiply the > number by the appropriate power of 10, round or truncate to an integer, > and > then divide by the same power."). If you're only rounding & truncating > one > variable, the REPEAT syntax would be unnecessary. > > *** Writes test data . > > DATA LIST FREE > /var001 (F8.3) var002 (F8.3) var003 (F8.3) . > BEGIN DATA > 1.011 1.011 1.011 > 1.016 1.016 1.016 > 11.011 11.011 11.011 > 11.016 11.016 11.016 > 111.011 111.011 111.011 > 111.016 111.016 111.016 > END DATA . > LIST . > > *** Uses REPEAT to round and truncate all variables . > > DO REPEAT a = var001 to var003 /b = rnd001 to rnd003 /c = new001 to new003 > . > + COMPUTE b = RND(a/.01) . > + COMPUTE c = b*.01 . > END REPEAT . > > > > Best, > > --Justin > > -- > Justin Black > Doctoral Student > Industrial-Organizational Psychology > Baruch College, CUNY > > > On Dec 24, 2007 10:31 AM, Peck, Jon <[hidden email]> wrote: > > > If you just want the display to be rounded, you can set the variable > > format to F12.2 with the FORMAT command. If you want the actually value > > to be changed to the rounded value, the usual way is to multiply the > number > > by the appropriate power of 10, round or truncate to an integer, and > then > > divide by the same power. > > > > HTH, > > Jon Peck > > > > -----Original Message----- > > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > > Samuel Solomon > > Sent: Monday, December 24, 2007 5:23 AM > > To: [hidden email] > > Subject: Re: [SPSSX-L] rounding and truncating > > > > yes but can you do it using syntax. RND returns an integer and so does > > TRUNC and I don't want that. for instance I have a numeric variable > > populated by decimal numbers. it is in a format f12.5. I want it to be > > rounded to f12.2 through syntax. > > thanks, > > Samuel > > ===================== > 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 ===================== 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 |
Is that an SPSS function ("changing the print format")? I'd be open to that
as an alternative. But if you're talking about changing the print format in Excel, that could become tedious for batch jobs... On Dec 24, 2007 4:16 PM, ViAnn Beadle <[hidden email]> wrote: > Wouldn't just changing the print format meet these requirements? > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Justin Black > Sent: Monday, December 24, 2007 1:28 PM > To: [hidden email] > Subject: Re: rounding and truncating > > Agreed, except there are at least two other applications - for > presentation > purposes and quality control. I have rounded and truncated in the past > for > exporting data to Excel for delivery in a "report" format; and also to > produce QC files that can be checked against reports generated from the > same > data but using a different medium (SQL, e.g.). > > --Justin > > On Dec 24, 2007 3:03 PM, ViAnn Beadle <[hidden email]> wrote: > > > All this begs the question as to why anybody would to do this. IMHO, > > discarding precision in this way doesn't seem to be useful unless this > is > > an > > accounting application and the metric is dollars and cents. > > > > -----Original Message----- > > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > > Justin Black > > Sent: Monday, December 24, 2007 12:30 PM > > To: [hidden email] > > Subject: Re: rounding and truncating > > > > Samuel, > > > > Below is an example of Jon's second suggestion ("If you want the > actually > > value to be changed to the rounded value, the usual way is to multiply > the > > number by the appropriate power of 10, round or truncate to an integer, > > and > > then divide by the same power."). If you're only rounding & truncating > > one > > variable, the REPEAT syntax would be unnecessary. > > > > *** Writes test data . > > > > DATA LIST FREE > > /var001 (F8.3) var002 (F8.3) var003 (F8.3) . > > BEGIN DATA > > 1.011 1.011 1.011 > > 1.016 1.016 1.016 > > 11.011 11.011 11.011 > > 11.016 11.016 11.016 > > 111.011 111.011 111.011 > > 111.016 111.016 111.016 > > END DATA . > > LIST . > > > > *** Uses REPEAT to round and truncate all variables . > > > > DO REPEAT a = var001 to var003 /b = rnd001 to rnd003 /c = new001 to > new003 > > . > > + COMPUTE b = RND(a/.01) . > > + COMPUTE c = b*.01 . > > END REPEAT . > > > > > > > > Best, > > > > --Justin > > > > -- > > Justin Black > > Doctoral Student > > Industrial-Organizational Psychology > > Baruch College, CUNY > > > > > > On Dec 24, 2007 10:31 AM, Peck, Jon <[hidden email]> wrote: > > > > > If you just want the display to be rounded, you can set the variable > > > format to F12.2 with the FORMAT command. If you want the actually > value > > > to be changed to the rounded value, the usual way is to multiply the > > number > > > by the appropriate power of 10, round or truncate to an integer, and > > then > > > divide by the same power. > > > > > > HTH, > > > Jon Peck > > > > > > -----Original Message----- > > > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf > Of > > > Samuel Solomon > > > Sent: Monday, December 24, 2007 5:23 AM > > > To: [hidden email] > > > Subject: Re: [SPSSX-L] rounding and truncating > > > > > > yes but can you do it using syntax. RND returns an integer and so does > > > TRUNC and I don't want that. for instance I have a numeric variable > > > populated by decimal numbers. it is in a format f12.5. I want it to be > > > rounded to f12.2 through syntax. > > > thanks, > > > Samuel > > > > ===================== > > 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 > > ===================== 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 |
It's an SPSS command, not a function. For example:
FORMATS myvar (F12.2). You can also specify a variable list: FORMATS var1 var2 vars (F12.2). ________________________________ From: SPSSX(r) Discussion on behalf of Justin Black Sent: Mon 12/24/2007 7:23 PM To: [hidden email] Subject: Re: rounding and truncating Is that an SPSS function ("changing the print format")? I'd be open to that as an alternative. But if you're talking about changing the print format in Excel, that could become tedious for batch jobs... On Dec 24, 2007 4:16 PM, ViAnn Beadle <[hidden email]> wrote: > Wouldn't just changing the print format meet these requirements? > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Justin Black > Sent: Monday, December 24, 2007 1:28 PM > To: [hidden email] > Subject: Re: rounding and truncating > > Agreed, except there are at least two other applications - for > presentation > purposes and quality control. I have rounded and truncated in the past > for > exporting data to Excel for delivery in a "report" format; and also to > produce QC files that can be checked against reports generated from the > same > data but using a different medium (SQL, e.g.). > > --Justin > > On Dec 24, 2007 3:03 PM, ViAnn Beadle <[hidden email]> wrote: > > > All this begs the question as to why anybody would to do this. IMHO, > > discarding precision in this way doesn't seem to be useful unless this > is > > an > > accounting application and the metric is dollars and cents. > > > > -----Original Message----- > > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > > Justin Black > > Sent: Monday, December 24, 2007 12:30 PM > > To: [hidden email] > > Subject: Re: rounding and truncating > > > > Samuel, > > > > Below is an example of Jon's second suggestion ("If you want the > actually > > value to be changed to the rounded value, the usual way is to multiply > the > > number by the appropriate power of 10, round or truncate to an integer, > > and > > then divide by the same power."). If you're only rounding & truncating > > one > > variable, the REPEAT syntax would be unnecessary. > > > > *** Writes test data . > > > > DATA LIST FREE > > /var001 (F8.3) var002 (F8.3) var003 (F8.3) . > > BEGIN DATA > > 1.011 1.011 1.011 > > 1.016 1.016 1.016 > > 11.011 11.011 11.011 > > 11.016 11.016 11.016 > > 111.011 111.011 111.011 > > 111.016 111.016 111.016 > > END DATA . > > LIST . > > > > *** Uses REPEAT to round and truncate all variables . > > > > DO REPEAT a = var001 to var003 /b = rnd001 to rnd003 /c = new001 to > new003 > > . > > + COMPUTE b = RND(a/.01) . > > + COMPUTE c = b*.01 . > > END REPEAT . > > > > > > > > Best, > > > > --Justin > > > > -- > > Justin Black > > Doctoral Student > > Industrial-Organizational Psychology > > Baruch College, CUNY > > > > > > On Dec 24, 2007 10:31 AM, Peck, Jon <[hidden email]> wrote: > > > > > If you just want the display to be rounded, you can set the variable > > > format to F12.2 with the FORMAT command. If you want the actually > value > > > to be changed to the rounded value, the usual way is to multiply the > > number > > > by the appropriate power of 10, round or truncate to an integer, and > > then > > > divide by the same power. > > > > > > HTH, > > > Jon Peck > > > > > > -----Original Message----- > > > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf > Of > > > Samuel Solomon > > > Sent: Monday, December 24, 2007 5:23 AM > > > To: [hidden email] > > > Subject: Re: [SPSSX-L] rounding and truncating > > > > > > yes but can you do it using syntax. RND returns an integer and so does > > > TRUNC and I don't want that. for instance I have a numeric variable > > > populated by decimal numbers. it is in a format f12.5. I want it to be > > > rounded to f12.2 through syntax. > > > thanks, > > > Samuel > > > > ===================== > > 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 > > ===================== 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 Justin Black
Thanks, that was what i was trying to achieve.
________________________________ From: SPSSX(r) Discussion on behalf of Justin Black Sent: Mon 12/24/2007 10:29 PM To: [hidden email] Subject: Re: rounding and truncating Samuel, Below is an example of Jon's second suggestion ("If you want the actually value to be changed to the rounded value, the usual way is to multiply the number by the appropriate power of 10, round or truncate to an integer, and then divide by the same power."). If you're only rounding & truncating one variable, the REPEAT syntax would be unnecessary. *** Writes test data . DATA LIST FREE /var001 (F8.3) var002 (F8.3) var003 (F8.3) . BEGIN DATA 1.011 1.011 1.011 1.016 1.016 1.016 11.011 11.011 11.011 11.016 11.016 11.016 111.011 111.011 111.011 111.016 111.016 111.016 END DATA . LIST . *** Uses REPEAT to round and truncate all variables . DO REPEAT a = var001 to var003 /b = rnd001 to rnd003 /c = new001 to new003 . + COMPUTE b = RND(a/.01) . + COMPUTE c = b*.01 . END REPEAT . Best, --Justin -- Justin Black Doctoral Student Industrial-Organizational Psychology Baruch College, CUNY On Dec 24, 2007 10:31 AM, Peck, Jon <[hidden email]> wrote: > If you just want the display to be rounded, you can set the variable > format to F12.2 with the FORMAT command. If you want the actually value > to be changed to the rounded value, the usual way is to multiply the number > by the appropriate power of 10, round or truncate to an integer, and then > divide by the same power. > > HTH, > Jon Peck > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Samuel Solomon > Sent: Monday, December 24, 2007 5:23 AM > To: [hidden email] > Subject: Re: [SPSSX-L] rounding and truncating > > yes but can you do it using syntax. RND returns an integer and so does > TRUNC and I don't want that. for instance I have a numeric variable > populated by decimal numbers. it is in a format f12.5. I want it to be > rounded to f12.2 through syntax. > thanks, > Samuel > > ________________________________ > > From: SPSSX(r) Discussion on behalf of Martin P. Holt > Sent: Mon 12/24/2007 2:40 PM > To: [hidden email] > Subject: Re: rounding and truncating > > > > Dear Samuel, > > to two decimal places means X.xx, to three means X.xxx, etc. > > Rounding is all to do with less than or greater than .5 (or .05 or .005 > etc). > > So 24.635 rounds to 24.64, to two decimal places. > > There are no hard and fast rules about rounding (e.g. do you round up, or > down). You basically need a policy document saying what rules you are > following. > > HTH, > > Martin Holt > > ===================== > 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 > > ===================== > 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 ====================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 Martin P. Holt-2
How about get crosstab output to round the column %?
I would like to show the column % with no decimal place.
CROSSTABS
/TABLES=
var1
BY
var2
/FORMAT=AVALUE TABLES
/CELLS=COUNT COLUMN
/COUNT ROUND CELL.
I have tried the advice here (F2.0) but can't get it to work.
Perry
|
You can't quite set the decimals automatically,
because the percent statistic is not based on the format of the variables,
and you can't do this with a tableLook, either. You could write an
autoscript for this if you are familiar with scripting.
However, you can do this with the SPSSINC MODIFY TABLES extension command available from SPSS Developer Central, www.spss.com/devcentral without any scripting knowledge. Here is an example. CROSSTABS /TABLES=hlth1 BY hlth2 /CELLS=COUNT ROW COLUMN TOTAL. SPSSINC MODIFY TABLES subtype="'Crosstabulation'" SELECT="<<ALL>>" /STYLES CUSTOMFUNCTION="customstylefunctions.SetDecimalPlaces(decimals=0)". This extension command requires the Python programmability plugin and at least V17 (or maybe 18 for this particular feature). Jon Peck Senior Software Engineer, IBM [hidden email] 312-651-3435 From: PerryGrossman <[hidden email]> To: [hidden email] Date: 11/29/2010 10:08 AM Subject: Re: [SPSSX-L] rounding and truncating Sent by: "SPSSX(r) Discussion" <[hidden email]> How about get crosstab output to round the column %? I would like to show the column % with no decimal place. CROSSTABS /TABLES= var1 BY var2 /FORMAT=AVALUE TABLES /CELLS=COUNT COLUMN /COUNT ROUND CELL. I have tried the advice here (F2.0) but can't get it to work. Perry View this message in context: Re: rounding and truncating Sent from the SPSSX Discussion mailing list archive at Nabble.com. |
Hi,
Thanks, I am using v19. I downloaded: SPSS_Statistics_PythonEssentials_19_win64.exe http://www.spss.com/devcentral/com/downloads.cfc I then tried to run the syntax you indicated (making adjustments for the variable names in my file, and adjustment to row %) yielding: >Error # 1. Command name: SPSSINC >The first word in the line is not recognized as an SPSS Statistics command. Then I reviewed devcentral and thought I might need to use "Begin" and "End Program." I tried various versions of that which didn't work, e.g.: BEGIN PROGRAM. import spssaux CROSSTABS /TABLES=n10 BY respWPSfocus /CELLS=COUNT COLUMN /COUNT ROUND CELL. SPSSINC MODIFY TABLES subtype="'Crosstabulation'" SELECT="<<ALL>>" /STYLES CUSTOMFUNCTION="customstylefunctions.SetDecimalPlaces(decimals=0)". END PROGRAM. File "<string>", line 4 /TABLES=n10 BY respWPSfocus ^ IndentationError: unexpected indent Then I searched specifically for the "SPSSINC MODIFY TABLES extension command" on devcentral, which only turned up this brief reference: http://www.spss.com/sites/dm-book/resources/ProgDataMgmt_19_book.pdf This looked more promising, but I couldn't find the specific command: http://www.spss.com/devcentral/files/articles/ExtensionCommandsOnDeveloperCentral.pdf Perry |
See below.
Jon Peck Senior Software Engineer, IBM [hidden email] 312-651-3435 From: PerryGrossman <[hidden email]> To: [hidden email] Date: 11/29/2010 08:13 PM Subject: Re: [SPSSX-L] rounding and truncating Sent by: "SPSSX(r) Discussion" <[hidden email]> Hi, Thanks, I am using v19. I downloaded: SPSS_Statistics_PythonEssentials_19_win64.exe http://www.spss.com/devcentral/com/downloads.cfc >>>Did this install without errors when you ran it? I then tried to run the syntax you indicated (making adjustments for the variable names in my file, and adjustment to row %) yielding: >Error # 1. Command name: SPSSINC >The first word in the line is not recognized as an SPSS Statistics command. >>>This indicates that the extension command has not been installed or is installed incorrectly. Then I reviewed devcentral and thought I might need to use "Begin" and "End Program." I tried various versions of that which didn't work, e.g.: >>>Extension commands do not require any programmability syntax. They work like regular commands once installed. BEGIN PROGRAM. import spssaux CROSSTABS /TABLES=n10 BY respWPSfocus /CELLS=COUNT COLUMN /COUNT ROUND CELL. SPSSINC MODIFY TABLES subtype="'Crosstabulation'" SELECT="<<ALL>>" /STYLES CUSTOMFUNCTION="customstylefunctions.SetDecimalPlaces(decimals=0)". END PROGRAM. File "<string>", line 4 /TABLES=n10 BY respWPSfocus ^ IndentationError: unexpected indent Then I searched specifically for the "SPSSINC MODIFY TABLES extension command" on devcentral, which only turned up this brief reference: http://www.spss.com/sites/dm-book/resources/ProgDataMgmt_19_book.pdf >>>In V19, some of the most popular extension commands, including this one, are installed automatically with the Essentials. It appears that that hasn't happened in this case. Can you report what happened when you ran the Essentials install? If it was successful, you should also see a menu item, Modify Table Appearance, under Utilities. For other extensions or with earlier SPSS versions, to find downloads, go to the Downloads link in the upper right corner of the main page. It's easiest if you then click single-page view. You can filter on extension commands. You will find them listed alphabetically. The installation instructions This looked more promising, but I couldn't find the specific command: http://www.spss.com/devcentral/files/articles/ExtensionCommandsOnDeveloperCentral.pdf Perry -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Re-rounding-and-truncating-tp1079913p3285550.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 |
Hi,
I didn't get any errors on the install. The installer went through to "finish." Python26 is now installed. And I got this list of resources: "A python interface to the XD API" (which comes up in a browser). There was not "menu item, Modify Table Appearance, under Utilities." There were no files listed in "Utilities"... "view installed extension bundles." I checked the SPSS folders. There were no files in "extensions" There are 9 files in "Python Essentials." including "SPSSINC_MODIFY_TABLES." I tried to open that in SPSS but it timed out. (I can read it in Notepad.) I did repair python essentials http://www.spss.com/devcentral/index.cfm?pg=downloadDet&dId=79 It did not report any errors. It just said click on "finish" Then I went to http://www.spss.com/devcentral/index.cfm?pg=downloadDet&dId=79 to try to d/l the extensions. The terminal showed up briefly on the screen. No changes occurred in the "extensions" folder, and Modify Table Appearance, does not appear under Utilities. Perry |
Free forum by Nabble | Edit this page |