Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

List Variables: How to output -0.55 instead of -.55?

6 views
Skip to first unread message

Bruce Weaver

unread,
Jan 21, 2000, 3:00:00 AM1/21/00
to
Hi group,
I am using output from LIST VARIABLES as input for another
(Pascal) program. The 2nd program cannot cope with numbers like .55 or
-.55. It needs them to be formatted as 0.55 and -0.55. I have been using
search and replace to change ' .' to '0.' and ' -' to '-0', but it would
be a lot handier if I could get SPSS to produce the formats I need in the
first place. Does anyone know how to do this?

Cheers,
Bruce
--
Bruce Weaver
Clinical Epidemiology & Biostatistics
McMaster University
E-mail: wea...@fhs.csu.mcmaster.ca
Homepage: http://www.angelfire.com/wv/bwhomedir

Rafael Osorio

unread,
Jan 21, 2000, 3:00:00 AM1/21/00
to
Dear Bruce,

There's an easy trick to overcome your problem using the
custom currency formats.

What you have to do is to set a 0 as the prefix, instead of
a dollar sign.

This way, a value like .55 will be displayed in the list as
0.55, and -.55 as -0.55.

The only drawback to this approach is that values like 2.55,
or -2.55, will be displayed as 02.55/-02.55

The syntax lines below will do the trick

SET CCA = '-,0,,'.

FORMAT var1 var2 var3... (CCA9.2).

I hope this trick will do the job for you...

Rafael Osorio

IPEA - Institute of Applied Economic Research
Brasilia/DF
Brasil


* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful

Rich Ulrich

unread,
Jan 21, 2000, 3:00:00 AM1/21/00
to
On Fri, 21 Jan 2000 08:39:21 -0500, Bruce Weaver
<wea...@fhs.csu.McMaster.CA> wrote:

> I am using output from LIST VARIABLES as input for another
> (Pascal) program. The 2nd program cannot cope with numbers like .55 or
> -.55. It needs them to be formatted as 0.55 and -0.55. I have been using
> search and replace to change ' .' to '0.' and ' -' to '-0', but it would
> be a lot handier if I could get SPSS to produce the formats I need in the
> first place. Does anyone know how to do this?

- Gee, you have to edit to get rid of the LIST VARs garbage, anyway.
The better way to pass along output is with WRITE OUTFILE=" ... "
and that gives *some* other sort of control over formats.

But if you really want the ".", I think I remember that WRITE might
like to drop out the decimals, entirely.... Well, it is something
extra to try.

--
Rich Ulrich, wpi...@pitt.edu
http://www.pitt.edu/~wpilib/index.html

Bruce Weaver

unread,
Jan 21, 2000, 3:00:00 AM1/21/00
to
On Fri, 21 Jan 2000, Rafael Osorio wrote:

> Dear Bruce,
>
> There's an easy trick to overcome your problem using the
> custom currency formats.
>
> What you have to do is to set a 0 as the prefix, instead of
> a dollar sign.
>
> This way, a value like .55 will be displayed in the list as
> 0.55, and -.55 as -0.55.
>
> The only drawback to this approach is that values like 2.55,
> or -2.55, will be displayed as 02.55/-02.55
>
> The syntax lines below will do the trick
>
> SET CCA = '-,0,,'.
>
> FORMAT var1 var2 var3... (CCA9.2).
>
> I hope this trick will do the job for you...
>
>
>
> Rafael Osorio
>

Thanks, Rafael. That does indeed do the trick. I also took another look
at WRITE OUTFILE, as suggested by Rich Ulrich. Here's the syntax,
followed by the text file it produced:

write outfile="c:\okatt\vitd\fleiss\tox_all.txt"
/trial ntot Y var_y .
execute.

1.0 160 0.000 0.775
2.0 3270 0.353 0.059
4.0 276 01.084 02.652
5.0 50 01.099 02.590
8.0 66 -0.556 02.603
9.0 348 01.912 02.274
10.0 80 01.196 02.618
12.0 86 0.000 03.955
13.0 58 0.000 03.933
14.0 622 0.275 0.079
16.0 246 0.191 0.176
25.0 50 0.000 03.923

As you Rafael said, there are leading zeroes where they are not needed
(e.g., 01.196), but these do not cause any problems for the program that
reads the data.

As for WRITE OUTFILE, it is fine as long as you want to write out ALL of
the cases in the data file. But I cannot find a way to make it write out
a subset of cases that meet some criteria--and this is what I want to do
in most cases. So I think I'll stick with LIST VARIABLES and just copy
from the draft output and paste into a text editor.

Many thanks to Rafael & Rich.

Cheers,
Bruce
--
Bruce Weaver

wea...@fhs.csu.mcmaster.ca
http://www.angelfire.com/wv/bwhomedir/

Neila Nessa

unread,
Jan 22, 2000, 3:00:00 AM1/22/00
to
WRITE is a transformation and hence you can do things like this!!!
It also accepts a formatting directive (put it together with the CCFs
and you are in great shape.
Neila

DATA LIST FREE / A B C.
BEGIN DATA
1 2 3
-4 3 2
4 3 5
4 6 5
67 6 5
56 67 6
54 6 656
-6 65 5
34 33 3
END DATA .

DO IF A < 4 .
WRITE OUTFILE "D:\TEST\A_LT4.TXT" / A B C (3F4.0) .
ELSE IF A >= 4 .
WRITE OUTFILE "D:\TEST\A_GE4.TXT" / A (F3) B C (2F6.4) .
END IF .
DO IF RANGE (B,33,67).
COMPUTE FLAGGED = 1.
WRITE OUTFILE "D:\TEST\BR_33_67.TXT" / A FLAGGED B ( F1.0, X / F4.2) .
END IF.
EXE .

Bruce Weaver <wea...@fhs.csu.McMaster.CA> wrote in message
news:Pine.HPP.3.91.100012...@fhs.csu.McMaster.CA...

0 new messages