automatically take data from table and insert into text

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

NS_SPSS_Guy
Posts: 9
Joined: Wed Aug 29, 2012 12:52 pm

automatically take data from table and insert into text

Postby NS_SPSS_Guy » Fri Feb 08, 2013 1:18 pm

I was wondering if it was possible to have data from a table (crosstabs or custom tables) be entered automatically into a text box in the output.

For example, if I had a 2x2 crosstab:

A | B
------
C | D

and I had the following text

"We found that (cell A)% of male students had a passing grade, while (cell B)% of female students had a passing grade..."

Is there a way (syntax command?) to have the text (which is in the output) automatically take the data from the table and insert it into the text?

Thanks!
JonPedersen
Posts: 118
Joined: Wed May 25, 2011 7:07 am
Contact:

Re: automatically take data from table and insert into text

Postby JonPedersen » Thu Feb 14, 2013 6:21 pm

Hi,
No and yes. No, because there is no simple syntax command. Yes: If you have very standardized written reports you can write the output to a file with the OMS facility, probably massage the data a bit afterwards in SPSS and then use mail merge with word (or whatever word processor you use) to enter the data into the text. If you really want to be fancy about it you could write a script in Python or Basic that would automate the whole thing.
best
Jon
NS_SPSS_Guy
Posts: 9
Joined: Wed Aug 29, 2012 12:52 pm

Re: automatically take data from table and insert into text

Postby NS_SPSS_Guy » Wed Feb 20, 2013 5:00 pm

Thanks Jon!

I was wondering if you could clarify what an OMS facility is?

The report we're attempting to automate contains about 50 crosstabs, tables, means and frequencies. These tables etc. are referenced in an intrepretation sheet that is situated at the begining of the document. Currently everything is done manually and is quite labour intensive.

The reports are quite standardized in that we are reporting the same stats for several different locations.

I was also wondering if you had an example of this or how it might work?

Thanks again!
JonPedersen
Posts: 118
Joined: Wed May 25, 2011 7:07 am
Contact:

Re: automatically take data from table and insert into text

Postby JonPedersen » Thu Feb 21, 2013 8:12 pm

Hi,
Consider this code:

Code: Select all

DATASET DECLARE  Crosstabset.
OMS
  /SELECT TABLES
  /IF COMMANDS=['Crosstabs'] SUBTYPES=['Crosstabulation']
  /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
   OUTFILE='Crosstabset'.
CROSSTABS womedu by womage /cells col.
OMSEND. 
It declares a new dataset, defines the output - it means basically that you want to save the crosstable (you will find the OMS control panel in the utilities menu)
then runs the crosstab you want (here just some data I happen to have open).
OMSEND is necessary to stop the output.
The result (apart from the usual one) is a dataset that is called Crosstabset (because I called it that).
It looks like this
womedu -99 % within womage . 0.03645643456069996 . . . 0.08849557522123894 . 0.015560569516844317
womedu 1 % within womage 11.928283937065496 19.57710535909588 20.796064400715565 19.366197183098592 22.14182344428365 26.371681415929203 26.486486486486488 19.50517388936435
womedu 2 % within womage 39.04134650567143 33.21181188479766 37.119856887298745 38.38028169014084 35.96237337192474 36.637168141592916 42.7027027027027 37.09639772815685
womedu 3 % within womage 49.03036955726308 47.17462632154575 42.08407871198569 42.25352112676056 41.89580318379161 36.902654867256636 30.810810810810814 43.382867812961955
Total % within womage 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0

(each line starts with womedu(although there is a bit more). The point is that you get a file with the tabulation, and you can pick out what you want from that one.

Hope this get you started.
best
jon

Who is online

Users browsing this forum: No registered users and 1 guest

cron