AMIN+N for ALTER TYPE not working?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

AMIN+N for ALTER TYPE not working?

ploverid
Hi...

...new member, so please forgive any etiquette lapses... and relatively new SPSS and Python user, so the source of my problems may well lie in ignorance! :)

I'm trying to use the ALTER TYPE command to increase a string variable's length dynamically, and can't seem to get it to work.

From the Alter Type Overview page, the specification is:

ALTER TYPE varlist([input format = ] {output format    }) [varlist...]
                                     {AMIN [+ [n[%]]   }
                                     {AHEXMIN [+ [n[%]]}
  [/PRINT {[ALTEREDTYPES*] [ALTEREDVALUES]}]
          {NONE                          }


And I'm focused on the "{AMIN [+ [n[%]]   }"  part which, according to the Alter Type Overview page's Options section works as follows:

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

Implementing this as "ALTER TYPE VarA (AMIN+20)." or "ALTER TYPE VarA (AMIN+20)." seems to do the same thing, which doesn't 'fully' set the String length of VarA to the current minimum length plus 20 characters.  

In the Wariable View, VarA's "Width" value is set correctly, and so is the Characters value in the pop-up window obtained by clicking on the "..." next to "String" in the Type column.

But I cannot add characters beyond the AMIN length!  I.e. the Variable View seems to be telling me that the lengths are set correctly, but then adding more characters to the string is not possible, manually (in the Data View) or via Script.)

For example, stepping through each of the following commands (with an exiting data file open, so that the number of cases is already set):

STRING VarA (A100).
COMPUTE VarA = 'ab'.
EXECUTE.
ALTER TYPE VarA (AMIN+20).
COMPUTE VarA = "12345".
EXECUTE.
ALTER TYPE VarA (A=AMIN).


After the VarA string variable has been created (line 1), its String 'Characters' and 'Width' attribute[?] values are both 100.  (It's Columns attribute value is 26, but this should(?) be irrelevant.)  [Is "attribute" the right word here?]

After EXECUTE-ing the first COMPUTE command (lines 2&3), none of the attributes have changed.  The string now holds the two character string 'ab'.

After the first ALTER TYPE command (line 4), the String 'Characters' and 'Width' attribute(?) values are both 22 (the minimum needed length to hold the existing strings (which are all 'ab'); plus the added 20 characters).  No change to the values stored in the string.

But after After EXECUTE-ing the second COMPUTE command (lines 5&6), the string's values only change to '12', not to '12345'.  The Variable View still shows the String 'Characters' and 'Width' attribute(?) values as 22.  At this point, manually changing value via the Data View allows a new longer value to be input, but truncates it to only 2 characters.  

At this point, the string is *acting* as if the first ALTER TYPE command actually set the string length to AMIN, not to AMIN+20, even though the Variable View 'correctly' indicates the string length to be the AMIN+20.

After the second ALTER TYPE command (line 7), the string's values are unaffected, and the String 'Characters' and 'Width' attribute values are set to the (correct) AMIN value of 2.

Any thoughts on what I might be doing wrong here?  Or if the AMIN+N functionality of ALTER TYP isn't working properly?

Thanks,
Peter
Reply | Threaded
Open this post in threaded view
|

Re: AMIN+N for ALTER TYPE not working?

ploverid
p.s. Changing line 4 of my code to the following doesn't change anything:
ALTER TYPE VarA (A=AMIN+20).
Reply | Threaded
Open this post in threaded view
|

Re: AMIN+N for ALTER TYPE not working?

Jon K Peck
Running DISPLAY DICTIONARY after the ALTER TYPE command shows that the width setting was correctly changed, but the system is ignoring that in subsequent assignments and using the AMIN width, whether in a compute or in the DE (which also correctly shows the new width in Variable View).  AMIN by itself works correctly, but AMIN + 20 and AMIN+20% do not.

A bug has been filed.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        ploverid <[hidden email]>
To:        [hidden email],
Date:        05/30/2014 09:53 AM
Subject:        Re: [SPSSX-L] AMIN+N for ALTER TYPE not working?
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




p.s. Changing line 4 of my code to the following doesn't change anything:
*/ALTER TYPE VarA (A=AMIN+20). /*



--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/AMIN-N-for-ALTER-TYPE-not-working-tp5726292p5726293.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD