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

syntax for converting from string to numeric?

1,591 views
Skip to first unread message

Shelley Martin

unread,
Nov 30, 1999, 3:00:00 AM11/30/99
to
Hi,

I have a large Microsoft Access database that I've imported into SPSS (v
9.0) using the database query function. I am generally very happy with
how the conversion takes place, with one exception: although almost all
the fields/variables are numeric, SPSS assigns them as string
variables. I am well aware that I can change the variables one by one
from string to numeric, using the "Define Variable" window and selecting
the appropriate radio buttons. However, I would like to write a simple
syntax routine that would convert the variables all in one fell swoop,
and I do NOT want to have to create a new set of variables to do this.

I've read online help and have pored over manuals and I can't figure out
if this is possible. I will be very grateful for any help anyone can
give me.

Shelley
--
**********************************************************
Children today are tyrants. They contradict their parents,
gobble their food, and tyrannize their teachers.
-- Socrates, 470 -399 A.D.
**********************************************************

sean_f...@my-deja.com

unread,
Dec 1, 1999, 3:00:00 AM12/1/99
to
hello,

if spss is importing numeric as string it could be possible that the
first row of data is a string within that column.

spss will use the first row's properties within a column to determine
the column properties when importing.

i do not know of any other hints, so good luck.

Sent via Deja.com http://www.deja.com/
Before you buy.

Joel Wiesen

unread,
Dec 1, 1999, 3:00:00 AM12/1/99
to
A while ago someone posted this type of solution to this
list:

DATA LIST/ seqnum v1 to v3 1-4 (a).
BEGIN DATA
1292
3455
2379
END DATA.
LIST .

COMPUTE numvar=NUMBER(v3,F1).
MATCH FILES FILE=*
/KEEP seqnum v1 v2 numvar .
RENAME VARIABLES (numvar=v3) .
list.
EXE.


--
Joel P. Wiesen, Ph.D., Director
Applied Personnel Research
27 Judith Road
Newton, Massachusetts 02459-1715
(617) 244-8859
Wie...@personnelselection.com
www.personnelselection.com/apr.htm

We develop personnel selection systems to be valid,
reliable, fair, practical, and legal.
Learn about our test of mechanical aptitude:
www.personnelselection.com/wtma.htm
Learn about our test of programmer/analyst aptitude:
www.personnelselection.com/programmer.htm

Russ916

unread,
Dec 5, 1999, 3:00:00 AM12/5/99
to
>hello,
>
>if spss is importing numeric as string it could be possible that the
>first row of data is a string within that column.
>
>spss will use the first row's properties within a column to determine
>the column properties when importing.

If you know the Variable is supposed to be numeric then you can:
rename (var = var1).
compute var = num(var1,F8.0).

Warning! if the numeric var has decimals then you have to declare it first.

rename (var = var1).
numeric var (F8.1).
compute var = num(var1,F8.0).
** it looks weird but it keeps SPSS from messing up the decimal conversion.

I hope this helps
Russ

jferm...@gmail.com

unread,
Jul 4, 2017, 7:05:46 PM7/4/17
to
I know you posted this years ago, but I just wanted to let you know it saved me tons of time. I was trying to recode the darned things, all I need to do is delete the first case (truncated SurveyMonkey junk) from Excel before pulling it into SPSS. Thanks!

On Wednesday, December 1, 1999 at 1:00:00 AM UTC-7, sean_f...@my-deja.com wrote:
> hello,
>
> if spss is importing numeric as string it could be possible that the
> first row of data is a string within that column.
>
> spss will use the first row's properties within a column to determine
> the column properties when importing.
>
0 new messages