Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
changing length of a string with Syntax SPSS 16
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
baiyun  
View profile  
 More options Jan 18 2008, 9:26 am
Newsgroups: comp.soft-sys.stat.spss
From: baiyun <y...@hotmail.de>
Date: Fri, 18 Jan 2008 06:26:50 -0800 (PST)
Local: Fri, Jan 18 2008 9:26 am
Subject: changing length of a string with Syntax SPSS 16
Dear all,

I am testing SPSS 16, does anyone know how to change the length of a
string with syntax? According to SPSS, one can do that with syntax
(new features)

Thanks in advance!

Baiyun


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bruce Weaver  
View profile  
 More options Jan 18 2008, 12:55 pm
Newsgroups: comp.soft-sys.stat.spss
From: Bruce Weaver <bwea...@lakeheadu.ca>
Date: Fri, 18 Jan 2008 09:55:07 -0800 (PST)
Local: Fri, Jan 18 2008 12:55 pm
Subject: Re: changing length of a string with Syntax SPSS 16
On Jan 18, 9:26 am, baiyun <y...@hotmail.de> wrote:

> Dear all,

> I am testing SPSS 16, does anyone know how to change the length of a
> string with syntax? According to SPSS, one can do that with syntax
> (new features)

> Thanks in advance!

> Baiyun

I'd not heard this before, but your post prompted me to do a little
searching.  The command you want is ALTER TYPE.  Here is the Help file
entry for those who do not have v16.

------------- HELP for ALTER TYPE --------

Overview (ALTER TYPE command)

ALTER TYPE can be used to change the fundamental type (string or
numeric) or format of variables, including changing the defined width
of string variables.

Options
* You can use the TO keyword to specify a list of variables or the ALL
keyword to specify all variables in the active dataset.

* The optional input format specification restricts the type
modification to only variables in the list that match the input
format. If the input format doesn't include a width specification, all
variables that match the basic format are included. An input format
specification without a width specification includes all variables
that match the basic format, regardless of defined width.

* AMIN or AHEXMIN can be used as the output format specification to
change the defined width of a string variable to the minimum width
necessary to display all observed values of that variable without
truncation.

* AMIN + n or AHEXMIN + n sets the width of string variables to the
minimum necessary width plus n bytes.

* AMIN + n% or AHEXMIN + n% sets the width of string variables to the
minimum necessary width plus n percent of that width. The result is
rounded to an integer.

Basic Specification

The basic specification is the name of a variable in the active
dataset followed by an output format specification enclosed in
parentheses, as in:

ALTER TYPE StringVar (A4).

Syntax Rules

* All variables specified or implied in the variable list(s) must
exist in the active dataset.

* Each variable list must be followed by a format specification
enclosed in parentheses.

* Format specifications must be valid SPSS formats. For information on
valid format specifications, see Variable Types and Formats.

* If specified, the optional input format must be followed by an
equals sign and then the output format.

* If a variable is included in more than one variable list on the same
ALTER TYPE command, only the format specification associated with the
last instance of the variable name will be applied. (If you want to
"chain" multiple modifications for the same variable, use multiple
ALTER TYPE commands.)

Operations

* If the command does not include any AMIN or AHEXMIN format
specifications and does not include ALTEREDVALUES on the PRINT
subcommand, the command takes effect immediately. It does not read the
active dataset or execute pending transformations.

* If the command includes one or more AMIN or AHEXMIN format
specifications or includes ALTEREDVALUES on the PRINT subcommand, the
command reads the active dataset and causes execution of any pending
transformations.

* Converting a numeric variable to string will result in truncated
values if the numeric value cannot be represented in the specified
string width.

* Converting a string variable to numeric will result in a system-
missing value if the string contains characters that would be invalid
for the specified numeric format.

Examples

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 first ALTER TYPE command changes the formats of Numvar1 and
Numvar2 from F2 and F1 to F5.2 and F3.

* The next ALTER TYPE command converts all string variables between
StringDate1 and StringDate3 (in file order) with a defined string
width of 11 to the numeric date format DATE11 (dd-mmm-yyyy). The only
variable that meets these criteria is StringDate1; so that is the only
variable converted.

* The third ALTER TYPE command converts all string variables between
StringDate1 and StringDate3 with a defined string width of 10 to the
numeric date format ADATE11 (mm/dd/yyyy). In this example, this
conversion is applied to StringDate2 and StringDate3.

* The last ALTER TYPE command changes the defined width of all
remaining string variables to the minimum width necessary for each
variable to avoid truncation of any values. In this example,
StringVar1 changes from A20 to A4 and StringVar2 changes from A30 to
A5. This command reads the data and executes any pending
transformation commands.

Related Topics
ALTER TYPE
PRINT Subcommand (ALTER TYPE command)

--
Bruce Weaver
bwea...@lakeheadu.ca
www.angelfire.com/wv/bwhomedir
"When all else fails, RTFM."


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google