Wednesday, 17 June 2009

Alter type (change variable type)

alters the type of the variable and also changes the length. For example, to change numeric to string or vice versa. You can use this command for single, multiple or ALL variables in your file. Here is the command for all variables.

ALTER TYPE ALL (A=A200).

the above will convert all the numeric to string with 200 character length. But it does not allow you to create a new version of the variable (unlike RECODE OR AUTORECODE).

For a good description of converting variable type see this UCLA page:
http://www.ats.ucla.edu/stat/spss/faq/stringnum.htm

Another good page to look at this is at the following user comment in a google group:
http://groups.google.com/group/comp.soft-sys.stat.spss/browse_thread/thread/0560f3240bb41edc?pli=1

11 comments:

Pancho Mulongeni said...

Thanks so much! However, how would I alter the type of not all the variables but a subset, with out having to type
ALTER TYPE VAR1 (A50)
ALTER TYPE VAR2 (A50)
all over again.

Pancho Mulongeni said...
This comment has been removed by the author.
Pancho Mulongeni said...

DATA LIST FREE
/Numvar1 (F2) Numvar2 (F1)
StringVar1 (A20) StringVar2 (A30)
StringDate1 (A11) StringDate2 (A10) StringDate3 (A10).
BEGIN DATA
1 23 a234 b2345 28-Oct-2007 10/28/2007 10/29/2008
END DATA.
ALTER TYPE Numvar1 (F5.2) Numvar2 (F3).
ALTER TYPE
StringDate1 to StringDate3 (A11 = DATE11).
ALTER TYPE
StringDate1 to StringDate3 (A10 = ADATE10).
ALTER TYPE ALL (A=AMIN).

The above is just taken from the IBM SPSS help.

Hapto said...

Because I'm not a statistics monkey and I struggled with a REALLY CLEAR thing that worked (but given that my precious code worked and then didnt, here is an option for you)
---

To make all the missing values 99:

MISSING VALUES All (99).

---
To make all the values Numeric
ALTER TYPE ALL (F3).

(if 'F3' isn't it, change one piece of data manually with all the clickdown menus -- and look at the 'Variables' and look for what is different between your "string" and your manually changed "numeric"

nikkisa889 said...

It’s hard to seek out knowledgeable people on this matter, but you sound like you realize what you’re speaking about! Thanks play casino

yanmaneee said...

ralph lauren uk
hermes birkin
golden goose outlet
nike off white
supreme new york
christian louboutin shoes
christian louboutin shoes
yeezy boost 350
michael kors outlet online
cheap jordans

yanmaneee said...

yeezy
supreme clothing
christian louboutin outlet
hermes birkin
cheap jordans
yeezy
jordan sneakers
yeezy
jordan shoes
nike cortez

Darren Demers said...

alters the type of the variable and also changes the length. For example, to change numeric to string or vice versa. You can use this command for single, multiple or ALL variables in your file. Here is the command for all variables. bar necklace australia , bar necklace chile ,

Anonymous said...

Lire le rapport complet sacs de répliques en Chine Allez ici meilleur designer de répliques consultez ici dolabuy gucci

Anonymous said...

important site Get More Information content his comment is here important link important source

neyslethesl said...

a7z28e1d53 q1t42w3w30 w6u05o9z90 a5d25d7x70 q5s88l9k48 x5u97p0y82