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

7 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.

amir hamja said...

thanks.

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"

Prologic Corporation said...

This is a good article & good site.Thank you for sharing this article. It is help us following categorize:
healthcare, e commerce, programming, multi platform,inventory management, cloud-based solutions, it consulting, retail, manufacturing, CRM, technology means, digital supply chain management, Delivering high-quality service for your business applications,
Solutions for all Industries,packaged applications,business applications, Web services, data migration
Business intelligence, Business Development, Software Development etc.


Our address:
2002 Timberloch Place, Suite 200
The Woodlands, TX 77380
281-364-1799

prologic-corp

raybanoutlet001 said...

coach outlet
cheap jerseys wholesale
oakley sunglasses
ecco shoes
michael kors handbags
michael kors outlet
true religion jeans
toms outlet
michael kors handbags online
michael kors factory outlet