Quantcast

converting data format automatically

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

converting data format automatically

Florio Arguillas

Hi everyone,

 

Let’s say I have 100 variables.  All 100 were assigned F2.0 format.

 

Some of these variables really only have one digit and so, I just really just want these one-digit variables to be assigned an F1.0 format.

 

What would be the command to automatically change the format of the one-digit variables from F2.0 to F1.0 without individually specifying the variables that need re-formatting, while keeping the rest (those with 2-digits) intact. With Alter Type it looks like I have to individually specify those one-digit variables if I want to reformat them. It looks to me what I need is an automatic way of reformatting my variables efficiently.

 

I appreciate your responses.

 

Thanks.

 

Florio

===================== 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
|  
Report Content as Inappropriate

Re: converting data format automatically

Jon Peck
Changing the format width will have almost no effect on anything - the DE display or pivot tables or charts.  What are you trying to achieve?

If you still want to do this, it would take a data pass to find the variables with range 0-9 and modify their formats.  This would be just a few lines of Python code, but please confirm the purpose first.
On Thu, Jan 19, 2017 at 4:13 PM Florio Orocio Arguillas <[hidden email]> wrote:
















Hi everyone,



 



Let’s say I have 100 variables.  All 100 were assigned F2.0 format.



 



Some of these variables really only have one digit and so, I just really just want these one-digit variables to be assigned an F1.0 format.



 



What would be the command to automatically change the format of the one-digit variables from F2.0 to F1.0 without individually specifying the variables that need re-formatting, while keeping the rest (those with 2-digits) intact. With Alter

Type it looks like I have to individually specify those one-digit variables if I want to reformat them. It looks to me what I need is an automatic way of reformatting my variables efficiently.



 



I appreciate your responses.



 



Thanks.



 



Florio









=====================

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: converting data format automatically

David Marso
Administrator
In reply to this post by Florio Arguillas
Why?  To what end?

Florio Arguillas wrote
Hi everyone,

Let's say I have 100 variables.  All 100 were assigned F2.0 format.

Some of these variables really only have one digit and so, I just really just want these one-digit variables to be assigned an F1.0 format.

What would be the command to automatically change the format of the one-digit variables from F2.0 to F1.0 without individually specifying the variables that need re-formatting, while keeping the rest (those with 2-digits) intact. With Alter Type it looks like I have to individually specify those one-digit variables if I want to reformat them. It looks to me what I need is an automatic way of reformatting my variables efficiently.

I appreciate your responses.

Thanks.

Florio

=====================
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?"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: converting data format automatically

PRogman
In reply to this post by Florio Arguillas
Most often these are nominal/categorial variables in my experience. Manual work, or if you know which ones to change, or need to repeat the changes use (saved) syntax. To change display format use FORMATS and specify the variables to change. In the syntax window use the Variables window (Menu>Utilities>Variables...) for easy selection of your variables and then paste into syntax.

FORMATS
  var1 var2 var6
  var10
TO var40
  var75
                  (F1.0).

/PR


Florio Arguillas wrote
Hi everyone,

Let's say I have 100 variables.  All 100 were assigned F2.0 format.

Some of these variables really only have one digit and so, I just really just want these one-digit variables to be assigned an F1.0 format.

What would be the command to automatically change the format of the one-digit variables from F2.0 to F1.0 without individually specifying the variables that need re-formatting, while keeping the rest (those with 2-digits) intact. With Alter Type it looks like I have to individually specify those one-digit variables if I want to reformat them. It looks to me what I need is an automatic way of reformatting my variables efficiently.

I appreciate your responses.

Thanks.

Florio

=====================
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
|  
Report Content as Inappropriate

Re: converting data format automatically

Art Kendall
In reply to this post by Florio Arguillas
Over several decades we have frequently seen posts on this list that are due to the confusion between display (print) formats and storage formats. You do not save disk storage space by changing display formats. Numbers are still kept as double precision.
see
https://en.wikipedia.org/wiki/Double-precision_floating-point_format.

Please describe why you want to do this.

Are you trying to reduce the size in characters of fixed format output files?

Is there some kind of display where it makes a difference in the appearance of a listing, graphic, etc?
Art Kendall
Social Research Consultants
Loading...