Help with macro call list and table generation

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

Help with macro call list and table generation

Jonathon jonathonlittle@anu.edu.au

Hello SPSSers,

 

I would like to ask for some assistance with the following problem. 

 

I have approximately 100 district areas within which are nested 10-20 teams.  I would like to generate the same table for each team and then send this to the appropriate folder.  I have two macro variables !prodx and !prodx2.  With 100 districts and 10-20 teams I will have a macro call statement that is 1000 - 2000 lines long - not to mention that this is only one of several nested table designs that I would like to generate.  You will notice that there is a SELECT IF statement which is made to equal the value of the two macro variables which are listed in the call statement.  The macros are designed to take on String values.

 
Is there a better way to do this? Such as have some loop function or something that can cycle through all the macro combinations without having to list these in one huge macro call statement. 

 

*///////////////.

DEFINE !doit (prodx=!TOKENS(1)/prodx2=!TOKENS(1))             

SET MPRINT=yes.

TEMPORARY.

 

OMS

 /SELECT ALL

  /EXCEPTIF SUBTYPES = ['NOTES']

/DESTINATION FORMAT = HTML OUTFILE = !QUOTE(!CONCAT('T:\PERFORMANCE EVALUATION\Performance Reports\Regions\',!UNQUOTE (!prodx),'\Table 1 - Performance\',!UNQUOTE (!prodx2),' - Table 1 - Performance by region.HTM'))

VIEWER=no.

 

SELECT IF S_Location_id =!prodx.

SELECT IF S_Dep_id =!prodx2.

 

* General Tables.

TABLES

  /FORMAT BLANK MISSING('.')

  /OBSERVATION= v1

  /GBASE=CASES

  /TABLE= S_Location_id > S_Dep_id BY status_1

  /STATISTICS

  count(status_1( F5.0 ) 'Number')

  cpct(status_1( PCT5.1 ) 'Percent':  S_Location_id S_Dep_id )

  /TITLE !QUOTE(!CONCAT('April to September- Table 1 - Performance Status by District and District Team as at Census 01/10/2012.'))

  /CAPTION  !QUOTE(!CONCAT('Source: PROCALIS-A; Date Range: For all tickets starting between 01/04/2012 and 30/09/2012; ORGANISATION: ', !UNQUOTE(!prodx2))).

 

 

OMSEND.

SET MPRINT=NO.

!ENDDEFINE.

*///////////////.

 

****Macro Call statement*****.

!doit prodx='North District' prodx2='Inner City Area'.

Reply | Threaded
Open this post in threaded view
|

Re: Help with macro call list and table generation

Jon K Peck
Look into the SPSSINC SPLIT DATASET and SPSSINC PROCESS FILES extension commands.  They and the prerequisite Python Essentials are available from the SPSS Community site (www.ibm.com/developerworks/spssdevcentral).  Also, you might consider replacing the long deprecated TABLES command with CTABLES, which has a lot of functionality beyond TABLES and is fully supported.


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




From:        "Jonathon [hidden email]" <[hidden email]>
To:        [hidden email],
Date:        10/21/2012 02:02 AM
Subject:        [SPSSX-L] Help with macro call list and table generation
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hello SPSSers,
 
I would like to ask for some assistance with the following problem. 
 
I have approximately 100 district areas within which are nested 10-20 teams.  I would like to generate the same table for each team and then send this to the appropriate folder.  I have two macro variables !prodx and !prodx2.  With 100 districts and 10-20 teams I will have a macro call statement that is 1000 - 2000 lines long - not to mention that this is only one of several nested table designs that I would like to generate.  You will notice that there is a SELECT IF statement which is made to equal the value of the two macro variables which are listed in the call statement.  The macros are designed to take on String values.
 
Is there a better way to do this? Such as have some loop function or something that can cycle through all the macro combinations without having to list these in one huge macro call statement. 
 
*///////////////.
DEFINE !doit (prodx=!TOKENS(1)/prodx2=!TOKENS(1))             
SET MPRINT=yes.
TEMPORARY.
 
OMS
 /SELECT ALL
  /EXCEPTIF SUBTYPES = ['NOTES']
/DESTINATION FORMAT = HTML OUTFILE = !QUOTE(!CONCAT('T:\PERFORMANCE EVALUATION\Performance Reports\Regions\',!UNQUOTE (!prodx),'\Table 1 - Performance\',!UNQUOTE (!prodx2),' - Table 1 - Performance by region.HTM'))
VIEWER=no.
 
SELECT IF S_Location_id =!prodx.
SELECT IF S_Dep_id =!prodx2.
 
* General Tables.
TABLES
  /FORMAT BLANK MISSING('.')
  /OBSERVATION= v1
  /GBASE=CASES
  /TABLE= S_Location_id > S_Dep_id BY status_1
  /STATISTICS
  count(status_1( F5.0 ) 'Number')
  cpct(status_1( PCT5.1 ) 'Percent':  S_Location_id S_Dep_id )
  /TITLE !QUOTE(!CONCAT('April to September- Table 1 - Performance Status by District and District Team as at Census 01/10/2012.'))
  /CAPTION  !QUOTE(!CONCAT('Source: PROCALIS-A; Date Range: For all tickets starting between 01/04/2012 and 30/09/2012; ORGANISATION: ', !UNQUOTE(!prodx2))).
 
 
OMSEND.
SET MPRINT=NO.
!ENDDEFINE.
*///////////////.
 
****Macro Call statement*****.
!doit prodx='North District' prodx2='Inner City Area'.