How to change variable type and length using syntax

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

How to change variable type and length using syntax

Dedi Suryana

Dear Listers
 
 
Currently I have some string variables, in other to be able to merge with another data set I need to change the length of the string variable
for instance Var1 (A10) , and I want to change it become Var1 (A50).
Yes, I can do it manually from the variable view , but is there anyway to do this using syntax?
 
Your help will be highly appreciated.
 

--
Best Regards,
Dedi Suryana
Reply | Threaded
Open this post in threaded view
|

Re: How to change variable type and length using syntax

Jon K Peck
You can do this with the ALTER TYPE command.

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




From:        Dedi Suryana <[hidden email]>
To:        [hidden email]
Date:        01/30/2012 08:42 PM
Subject:        [SPSSX-L] How to change variable type and length using syntax
Sent by:        "SPSSX(r) Discussion" <[hidden email]>





Dear Listers

 
 
Currently I have some string variables, in other to be able to merge with another data set I need to change the length of the string variable
for instance Var1 (A10) , and I want to change it become Var1 (A50).
Yes, I can do it manually from the variable view , but is there anyway to do this using syntax?
 
Your help will be highly appreciated.
 

--
Best Regards,
Dedi Suryana

Reply | Threaded
Open this post in threaded view
|

Re: How to change variable type and length using syntax

Dedi Suryana
Dear Peck,
 
Thanks for your helps.
I have tried it, but it still not working, seems like because of I am using old SPSS version, so it does't support this command. Currently I am using SPSS 13.
 
I there any other alternatives?
 
Best regards,
Dedi


On 31 January 2012 10:46, Jon K Peck <[hidden email]> wrote:
You can do this with the ALTER TYPE command.

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: <a href="tel:720-342-5621" target="_blank" value="+17203425621">720-342-5621




From:        Dedi Suryana <[hidden email]>
To:        [hidden email]
Date:        01/30/2012 08:42 PM
Subject:        [SPSSX-L] How to change variable type and length using syntax
Sent by:        "SPSSX(r) Discussion" <[hidden email]>





Dear Listers

 
 
Currently I have some string variables, in other to be able to merge with another data set I need to change the length of the string variable
for instance Var1 (A10) , and I want to change it become Var1 (A50).
Yes, I can do it manually from the variable view , but is there anyway to do this using syntax?
 
Your help will be highly appreciated.
 

--
Best Regards,
Dedi Suryana




--
Best Regards,
Dedi Suryana
Reply | Threaded
Open this post in threaded view
|

Re: How to change variable type and length using syntax

David Marso
Administrator
In reply to this post by Dedi Suryana
Tedious? YES!!!
Better than point and click?  YMMV!
----------------
DATA LIST / A1 A2 A3 (3A10,X).
BEGIN DATA
abcdefghij abcdefghij abcdefghij
END DATA.
DO REPEAT OLD=A1 A2 A3 / NEW=A1x A2x A3x / TYPE=A20 A50 A60.
+  STRING NEW(TYPE).
+  COMPUTE NEW=OLD.
END REPEAT PRINT.
RENAME VARIABLES (A1 A2 A3 A1x A2x A3x= A1x A2x A3x A1 A2 A3).
MATCH FILES / FILE * / DROP A1x a2x A3x.
DISPLAY DICTIONARY.


            List of variables on the working file

Name                                                                   Position

A1                                                                            1
          Measurement Level: Nominal
          Column Width: 20  Alignment: Left
          Print Format: A20
          Write Format: A20

A2                                                                            4
          Measurement Level: Nominal
          Column Width: 24  Alignment: Left
          Print Format: A50
          Write Format: A50

A3                                                                           11
          Measurement Level: Nominal
          Column Width: 24  Alignment: Left
          Print Format: A60
          Write Format: A60



Dedi Suryana wrote
Dear Listers


Currently I have some string variables, in other to be able to merge with
another data set I need to change the length of the string variable
for instance Var1 (A10) , and I want to change it become Var1 (A50).
Yes, I can do it manually from the variable view , but is there anyway to
do this using syntax?

Your help will be highly appreciated.


--
Best Regards,
Dedi Suryana
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: How to change variable type and length using syntax

Rick Oliver-3
The ALTER TYPE command solves this problem quite easily.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]




From:        David Marso <[hidden email]>
To:        [hidden email]
Date:        01/31/2012 12:30 AM
Subject:        Re: How to change variable type and length using syntax
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Tedious? YES!!!
Better than point and click?  YMMV!
----------------
DATA LIST / A1 A2 A3 (3A10,X).
BEGIN DATA
abcdefghij abcdefghij abcdefghij
END DATA.
DO REPEAT OLD=A1 A2 A3 / NEW=A1x A2x A3x / TYPE=A20 A50 A60.
+  STRING NEW(TYPE).
+  COMPUTE NEW=OLD.
END REPEAT PRINT.
RENAME VARIABLES (A1 A2 A3 A1x A2x A3x= A1x A2x A3x A1 A2 A3).
MATCH FILES / FILE * / DROP A1x a2x A3x.
DISPLAY DICTIONARY.


           List of variables on the working file

Name
Position

A1
1
         Measurement Level: Nominal
         Column Width: 20  Alignment: Left
         Print Format: A20
         Write Format: A20

A2
4
         Measurement Level: Nominal
         Column Width: 24  Alignment: Left
         Print Format: A50
         Write Format: A50

A3
11
         Measurement Level: Nominal
         Column Width: 24  Alignment: Left
         Print Format: A60
         Write Format: A60




Dedi Suryana wrote
>
> Dear Listers
>
>
> Currently I have some string variables, in other to be able to merge with
> another data set I need to change the length of the string variable
> for instance Var1 (A10) , and I want to change it become Var1 (A50).
> Yes, I can do it manually from the variable view , but is there anyway to
> do this using syntax?
>
> Your help will be highly appreciated.
>
>
> --
> Best Regards,
> Dedi Suryana
>


--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/How-to-change-variable-type-and-length-using-syntax-tp5443553p5443656.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


Reply | Threaded
Open this post in threaded view
|

Re: How to change variable type and length using syntax

David Marso
Administrator
The OP indicated that version 13 was being used.
ALTER TYPE only solves it for more recent versions ;-)

On Tue, Jan 31, 2012 at 9:27 AM, Rick Oliver <[hidden email]> wrote:

> The ALTER TYPE command solves this problem quite easily.
>
> Rick Oliver
> Senior Information Developer
> IBM Business Analytics (SPSS)
> E-mail: [hidden email]
>
>
>
>
> From:        David Marso <[hidden email]>
> To:        [hidden email]
> Date:        01/31/2012 12:30 AM
> Subject:        Re: How to change variable type and length using syntax
> Sent by:        "SPSSX(r) Discussion" <[hidden email]>
> ________________________________
>
>
>
> Tedious? YES!!!
> Better than point and click?  YMMV!
> ----------------
> DATA LIST / A1 A2 A3 (3A10,X).
> BEGIN DATA
> abcdefghij abcdefghij abcdefghij
> END DATA.
> DO REPEAT OLD=A1 A2 A3 / NEW=A1x A2x A3x / TYPE=A20 A50 A60.
> +  STRING NEW(TYPE).
> +  COMPUTE NEW=OLD.
> END REPEAT PRINT.
> RENAME VARIABLES (A1 A2 A3 A1x A2x A3x= A1x A2x A3x A1 A2 A3).
> MATCH FILES / FILE * / DROP A1x a2x A3x.
> DISPLAY DICTIONARY.
>
>
>            List of variables on the working file
>
> Name
> Position
>
> A1
> 1
>          Measurement Level: Nominal
>          Column Width: 20  Alignment: Left
>          Print Format: A20
>          Write Format: A20
>
> A2
> 4
>          Measurement Level: Nominal
>          Column Width: 24  Alignment: Left
>          Print Format: A50
>          Write Format: A50
>
> A3
> 11
>          Measurement Level: Nominal
>          Column Width: 24  Alignment: Left
>          Print Format: A60
>          Write Format: A60
>
>
>
>
> Dedi Suryana wrote
>>
>> Dear Listers
>>
>>
>> Currently I have some string variables, in other to be able to merge with
>> another data set I need to change the length of the string variable
>> for instance Var1 (A10) , and I want to change it become Var1 (A50).
>> Yes, I can do it manually from the variable view , but is there anyway to
>> do this using syntax?
>>
>> Your help will be highly appreciated.
>>
>>
>> --
>> Best Regards,
>> Dedi Suryana
>>
>
>
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/How-to-change-variable-type-and-length-using-syntax-tp5443553p5443656.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
>
>

=====================
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"