old style frequencies

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

old style frequencies

Simon Phillip Freidin

I want to produce "old-style" frequencies in SPSS 17 from a production job to an OMS text file.

 

The OMS file loses all the box characters, so instead of this

 

HF5 Sex

 | ----- | --------- | --------- | ------- | ------------- | ---------- |

 |       |           | Frequency | Percent | Valid Percent | Cumulative |

 |       |           |           |         |               | Percent    |

 | ----- | --------- | --------- | ------- | ------------- | ---------- |

 | Valid | 1  Male   | 788       | 48.6    | 48.6          | 48.6       |

 |       | --------- | --------- | ------- | ------------- | ---------- |

 |       | 2  Female | 834       | 51.4    | 51.4          | 100.0      |

 |       | --------- | --------- | ------- | ------------- | ---------- |

 |       | Total     | 1622      | 100.0   | 100.0         |            |

 | ----- | --------- | --------- | ------- | ------------- | ---------- |

 

I get

 

HF5 Sex                                                                         

                       Frequency   Percent   Valid Percent   Cumulative Percent     

   Valid   1  Male     788         48.6      48.6            48.6        

           2  Female   834         51.4      51.4            100.0       

           Total       1622        100.0     100.0                       

 

Anyone know a workaround to restore the box characteristics?

 

 

Reply | Threaded
Open this post in threaded view
|

Re: old style frequencies

Peck, Jon

Why do you want the old format?  Note that OMS in v17 can now export in various Office formats as well as the ones it had before.

 

But if you still need to do this, there is no way to do it directly, but it would be simple to get this mostly right with a little Python post-processing of the output.  You could choose TABTEXT as the output format and then build the text that way.

 

Alternatively, you could export as XML (FORMAT=OXML) and then use an XSLT script to format the output however you want it.  That's a bit more work and requires knowing how to work with XML, but it would be more robust.  Or, without going the XSLT route, you could have OMS create a dataset or write to the XML workspace (XMLWORKSPACE="name") and using programmability to create the output in the format you want.

 

The functions createXmlOutput and getValuesFromXmlWorkspace in the spssaux module can take care of all the OMS construction and retrieval for you.

 

Here is an example using the employee data.sav file included with the system.  The example runs the FREQUENCIES command wrapped in appropriate OMS directives and gets the frequency table back.  "table" is a variable (a list) containing all the data from the frequency table in text format, so what would be left to do is to write out those data in whatever text format you want.  

 

begin program.

import spss, spssaux

tag = spssaux.createXmlOutput("FREQUENCIES jobcat", subtype="Frequencies", visible=True)

table = spssaux.getValuesFromXmlWorkspace(tag[0], "Frequencies", cellAttrib="text")

print table

end program.

 

HTH,

Jon Peck

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Simon Phillip Freidin
Sent: Thursday, June 04, 2009 11:57 PM
To: [hidden email]
Subject: [SPSSX-L] old style frequencies

 

I want to produce "old-style" frequencies in SPSS 17 from a production job to an OMS text file.

 

The OMS file loses all the box characters, so instead of this

 

HF5 Sex

 | ----- | --------- | --------- | ------- | ------------- | ---------- |

 |       |           | Frequency | Percent | Valid Percent | Cumulative |

 |       |           |           |         |               | Percent    |

 | ----- | --------- | --------- | ------- | ------------- | ---------- |

 | Valid | 1  Male   | 788       | 48.6    | 48.6          | 48.6       |

 |       | --------- | --------- | ------- | ------------- | ---------- |

 |       | 2  Female | 834       | 51.4    | 51.4          | 100.0      |

 |       | --------- | --------- | ------- | ------------- | ---------- |

 |       | Total     | 1622      | 100.0   | 100.0         |            |

 | ----- | --------- | --------- | ------- | ------------- | ---------- |

 

I get

 

HF5 Sex                                                                         

                       Frequency   Percent   Valid Percent   Cumulative Percent     

   Valid   1  Male     788         48.6      48.6            48.6        

           2  Female   834         51.4      51.4            100.0       

           Total       1622        100.0     100.0                       

 

Anyone know a workaround to restore the box characteristics?

 

 

Reply | Threaded
Open this post in threaded view
|

Re: old style frequencies

Oliver, Richard

In release 17 or later, use OUTPUT EXPORT, as in:

 

data list free /var1.

begin data

1 1 2 2 2 3

end data.

frequencies variables=var1.

output export /text documentfile='/temp/textborders.txt'.

 

This produces a table that looks like this:

 

var1

|-----------|---------|-------|-------------|---------------|

|           |Frequency|Percent|Valid Percent|Cumulative     |

|           |         |       |             |Percent        |

|-----|-----|---------|-------|-------------|---------------|

|Valid|1.00 |2        |33.3   |33.3         |33.3           |

|     |-----|---------|-------|-------------|---------------|

|     |2.00 |3        |50.0   |50.0         |83.3           |

|     |-----|---------|-------|-------------|---------------|

|     |3.00 |1        |16.7   |16.7         |100.0          |

|     |-----|---------|-------|-------------|---------------|

|     |Total|6        |100.0  |100.0        |               |

|-----|-----|---------|-------|-------------|---------------|

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Peck, Jon
Sent: Friday, June 05, 2009 9:37 AM
To: [hidden email]
Subject: Re: old style frequencies

 

Why do you want the old format?  Note that OMS in v17 can now export in various Office formats as well as the ones it had before.

 

But if you still need to do this, there is no way to do it directly, but it would be simple to get this mostly right with a little Python post-processing of the output.  You could choose TABTEXT as the output format and then build the text that way.

 

Alternatively, you could export as XML (FORMAT=OXML) and then use an XSLT script to format the output however you want it.  That's a bit more work and requires knowing how to work with XML, but it would be more robust.  Or, without going the XSLT route, you could have OMS create a dataset or write to the XML workspace (XMLWORKSPACE="name") and using programmability to create the output in the format you want.

 

The functions createXmlOutput and getValuesFromXmlWorkspace in the spssaux module can take care of all the OMS construction and retrieval for you.

 

Here is an example using the employee data.sav file included with the system.  The example runs the FREQUENCIES command wrapped in appropriate OMS directives and gets the frequency table back.  "table" is a variable (a list) containing all the data from the frequency table in text format, so what would be left to do is to write out those data in whatever text format you want.  

 

begin program.

import spss, spssaux

tag = spssaux.createXmlOutput("FREQUENCIES jobcat", subtype="Frequencies", visible=True)

table = spssaux.getValuesFromXmlWorkspace(tag[0], "Frequencies", cellAttrib="text")

print table

end program.

 

HTH,

Jon Peck

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Simon Phillip Freidin
Sent: Thursday, June 04, 2009 11:57 PM
To: [hidden email]
Subject: [SPSSX-L] old style frequencies

 

I want to produce "old-style" frequencies in SPSS 17 from a production job to an OMS text file.

 

The OMS file loses all the box characters, so instead of this

 

HF5 Sex

 | ----- | --------- | --------- | ------- | ------------- | ---------- |

 |       |           | Frequency | Percent | Valid Percent | Cumulative |

 |       |           |           |         |               | Percent    |

 | ----- | --------- | --------- | ------- | ------------- | ---------- |

 | Valid | 1  Male   | 788       | 48.6    | 48.6          | 48.6       |

 |       | --------- | --------- | ------- | ------------- | ---------- |

 |       | 2  Female | 834       | 51.4    | 51.4          | 100.0      |

 |       | --------- | --------- | ------- | ------------- | ---------- |

 |       | Total     | 1622      | 100.0   | 100.0         |            |

 | ----- | --------- | --------- | ------- | ------------- | ---------- |

 

I get

 

HF5 Sex                                                                         

                       Frequency   Percent   Valid Percent   Cumulative Percent     

   Valid   1  Male     788         48.6      48.6            48.6        

           2  Female   834         51.4      51.4            100.0       

           Total       1622        100.0     100.0                       

 

Anyone know a workaround to restore the box characteristics?

 

 

Reply | Threaded
Open this post in threaded view
|

Re: old style frequencies

Oliver, Richard
In reply to this post by Peck, Jon

You can also export to text output in this format using the Export dialog (File>Export). This method works in earlier versions as well. The syntax method was added in release 17.

 


From: Oliver, Richard
Sent: Friday, June 05, 2009 9:47 AM
To: Peck, Jon; [hidden email]
Subject: RE: Re: old style frequencies

 

In release 17 or later, use OUTPUT EXPORT, as in:

 

data list free /var1.

begin data

1 1 2 2 2 3

end data.

frequencies variables=var1.

output export /text documentfile='/temp/textborders.txt'.

 

This produces a table that looks like this:

 

var1

|-----------|---------|-------|-------------|---------------|

|           |Frequency|Percent|Valid Percent|Cumulative     |

|           |         |       |             |Percent        |

|-----|-----|---------|-------|-------------|---------------|

|Valid|1.00 |2        |33.3   |33.3         |33.3           |

|     |-----|---------|-------|-------------|---------------|

|     |2.00 |3        |50.0   |50.0         |83.3           |

|     |-----|---------|-------|-------------|---------------|

|     |3.00 |1        |16.7   |16.7         |100.0          |

|     |-----|---------|-------|-------------|---------------|

|     |Total|6        |100.0  |100.0        |               |

|-----|-----|---------|-------|-------------|---------------|

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Peck, Jon
Sent: Friday, June 05, 2009 9:37 AM
To: [hidden email]
Subject: Re: old style frequencies

 

Why do you want the old format?  Note that OMS in v17 can now export in various Office formats as well as the ones it had before.

 

But if you still need to do this, there is no way to do it directly, but it would be simple to get this mostly right with a little Python post-processing of the output.  You could choose TABTEXT as the output format and then build the text that way.

 

Alternatively, you could export as XML (FORMAT=OXML) and then use an XSLT script to format the output however you want it.  That's a bit more work and requires knowing how to work with XML, but it would be more robust.  Or, without going the XSLT route, you could have OMS create a dataset or write to the XML workspace (XMLWORKSPACE="name") and using programmability to create the output in the format you want.

 

The functions createXmlOutput and getValuesFromXmlWorkspace in the spssaux module can take care of all the OMS construction and retrieval for you.

 

Here is an example using the employee data.sav file included with the system.  The example runs the FREQUENCIES command wrapped in appropriate OMS directives and gets the frequency table back.  "table" is a variable (a list) containing all the data from the frequency table in text format, so what would be left to do is to write out those data in whatever text format you want.  

 

begin program.

import spss, spssaux

tag = spssaux.createXmlOutput("FREQUENCIES jobcat", subtype="Frequencies", visible=True)

table = spssaux.getValuesFromXmlWorkspace(tag[0], "Frequencies", cellAttrib="text")

print table

end program.

 

HTH,

Jon Peck

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Simon Phillip Freidin
Sent: Thursday, June 04, 2009 11:57 PM
To: [hidden email]
Subject: [SPSSX-L] old style frequencies

 

I want to produce "old-style" frequencies in SPSS 17 from a production job to an OMS text file.

 

The OMS file loses all the box characters, so instead of this

 

HF5 Sex

 | ----- | --------- | --------- | ------- | ------------- | ---------- |

 |       |           | Frequency | Percent | Valid Percent | Cumulative |

 |       |           |           |         |               | Percent    |

 | ----- | --------- | --------- | ------- | ------------- | ---------- |

 | Valid | 1  Male   | 788       | 48.6    | 48.6          | 48.6       |

 |       | --------- | --------- | ------- | ------------- | ---------- |

 |       | 2  Female | 834       | 51.4    | 51.4          | 100.0      |

 |       | --------- | --------- | ------- | ------------- | ---------- |

 |       | Total     | 1622      | 100.0   | 100.0         |            |

 | ----- | --------- | --------- | ------- | ------------- | ---------- |

 

I get

 

HF5 Sex                                                                         

                       Frequency   Percent   Valid Percent   Cumulative Percent     

   Valid   1  Male     788         48.6      48.6            48.6        

           2  Female   834         51.4      51.4            100.0       

           Total       1622        100.0     100.0                       

 

Anyone know a workaround to restore the box characteristics?