The agony and the ecstacy: Development of complex MATRIX programs.

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

Re: The agony and the ecstasy: Development of complex MATRIX programs.

David Marso
Administrator
This post was updated on .
Hanging my head in shame:
I confess to being the original perpetrator of this flavor of dynamic syntax generation (or maybe I should blame Neila Nessa ).  Some who will remain nameless have referred to it as a "horrible hack" ;-)
Many people will credit RL for this (or cite his site as example) but that is historically inaccurate.  OTOH,  I am not entirely certain I wish to be credited with it either given it's widespread deprecation.
One thing which is a crying shame is that all of the SPSS archives before 1996 have been bit bucketed .
Does anyone know why or how 6-10 years of archives have gone the way of Roanoke (I don't know exactly when SPSSX-L first started but Wikipedia INCORRECTLY cites 1996.  I was posting gems (or what I thought were so at the time) way back in 1991.
-----
DO IF ($CASENUM EQ 1).
WRITE /"spsscode....".
END IF.
EXE.
....
INCLUDE (or use/refer to it somewhere else)...

Marta García-Granero-2 wrote
Hi Kiril, long time

El 10/12/2012 18:39, Kirill Orlov escribió:
> ... SPSS development has become - to my subjective feeling - so much
> negligent that they didn't allowed using GPL within macros - just
> because GPL doesn't support quoting with apostrophes (which macro
> function !quote does). ....
But I DO have a macro with GPL code inside, thanks to ViAnn, who helped
a lot with the quote-unquote-double quote-single quote waltz needed.
Maybe it is another example of the bunblebee flying although it should
not be possible
(http://www.sciencenews.org/view/generic/id/5400/title/Math_Trek__Flight_of_the_Bumblebee).

Here is the macro, just in case it helps you.

BTW, fiddling with my old macros is like looking at an old photo album,
full of faded pictures...

Warmest regards,
Marta GG

*****************************************************************
*   KALBFLEISCH-PRENTICE 95% CI INTERVALS FOR SURVIVAL CURVES   *
*****************************************************************
* Kalbfleisch JD and Prentice RL(1980). The Statistical         *
* Analysis of Failure Time Data. New York: John Wiley & Sons    *
*****************************************************************
* (c) Marta Garcia-Granero (june 2005 - original code) modified *
* (turnt into macro) september 2008. [hidden email]  *
*****************************************************************
          * Downloaded from: http://gjyp.nl/marta/      *
          * Feel free to use or modify this code, but   *
          * acknowledge the author and the web site     *
          ***********************************************

* Unlike Greenwood's, the Kalbfleisch--Prentice approach has the attractive
   property that the upper and lower bounds are always between 0 and 1.

* MACRO definition *.
DEFINE KPSURVIVAL(!POS=!TOKENS(1)/!POS=!CHAREND('(')/!POS=!CHAREND(')')).
* Creating the chart template *.
PRESERVE.
SET RESULTS=NONE MESSAGES=NONE ERRORS=NONE.
HOST COMMAND=['IF not exist C:\Temp MD C:\Temp'].
HOST COMMAND=['DEL C:\Temp\*.sgt'].
RESTORE.
DO IF $casenum EQ 1.
* Dynamically create the template for the chart *.
WRITE OUTFILE='C:\Temp\KPTemplate.sgt'
/'<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
/'<template SPSS-Version="2.2" selectPath="12 47 "'
/' xmlns="http://xml.spss.com/spss/visualization"'
/' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
/' xsi:schemaLocation="http://xml.spss.com/spss/visualization'
/' http://xml.spss.com/spss/visualization/vizml-template-3.0.xsd">'
/'    <setAxisMargin categorical="false" lowerMargin="0%" role="x"
upperMargin="5%"/>'
/'    <setAxisMargin categorical="false" lowerMargin="0%" role="y"
upperMargin="5%"/>'
/'    <addFrame count="1" styleOnly="true" type="visualization">'
/'        <style color="#ffffff" color2="transparent" number="0"
visible="true"/>'
/'        <style font-family="SansSerif" font-size="8pt" number="1"
pattern="0" stroke-linecap="butt" text-fit="true" visible="true"/>'
/'    </addFrame>'
/'    <addFrame count="1" styleOnly="true" type="graph">'
/'        <style color="transparent" color2="transparent" visible="true"/>'
/'        <style color="#ffffff" color2="transparent" number="1"
visible="true"/>'
/'    </addFrame>'
/'    <addFrame count="1" styleOnly="true" type="title">'
/'        <style color="transparent" color2="transparent" visible="true"/>'
/'    </addFrame>'
/'</template>'.
END IF.
EXECUTE.
DATASET NAME OriginalData.
* Copy data to leave original unmodified *.
DATASET COPY WorkingData1 WINDOW=MINIMIZED.
DATASET DECLARE AuxData WINDOW=HIDDEN.
DATASET ACTIVATE WorkingData1.
COMPUTE status=(!2 EQ !3).
RENAME VARIABLES (!1 = time).
* Get rid of every other variable *.
MATCH FILES FILE=*
  /KEEP=time status.
* Save sorted file to match CI limits later *.
SORT CASES BY time(A).
DATASET COPY WorkingData2  WINDOW=MINIMIZED.
* Saving KM survival estimates *.
PRESERVE.
SET ERRORS=NONE RESULTS=NONE.
KM time /STATUS=status(1)
   /PRINT NONE
   /PLOT SURVIVAL
   /SAVE SURVIVAL  .
* Total sample size *.
RANK VARIABLES=time(A) /N INTO totaln/PRINT=NO.
* Preparing data to compute pj and Std Error of Log(survival) *.
AGGREGATE /OUTFILE = *  MODE=REPLACE
   /BREAK = time
   /aj = SUM(status)
   /sj = FIRST(SUR_1)
   /totaln = FIRST(totaln)
   /N = n.
* Auxiliary file #1 *.
MATRIX.
COMPUTE time=0.
COMPUTE aj=0.
COMPUTE sj=1.
COMPUTE totaln=0.
COMPUTE n=0.
COMPUTE vnames={'time','aj','sj','totaln','n'}.
COMPUTE newdata={time,aj,sj,totaln,n}.
SAVE newdata /OUTFILE='AuxData'/NAMES=vnames.
END MATRIX.
* Adding time 0 data (from auxiliary file)*.
ADD FILES /FILE=*
  /FILE='AuxData'
  /IN=source.
IF source EQ 1 totaln=LAG(totaln).
SORT CASES BY time(A).
* Computing auxiliary statistics *.
COMPUTE rj=totaln.
DO IF $casenum GT 1.
- COMPUTE n = n+LAG(n) .
- COMPUTE rj= totaln-LAG(n).
END IF.
EXECUTE ./* Don't eliminate it (necessary) *.
* Getting rid of censored data *.
SELECT IF NOT MISSING(sj).
* More statistics and reordering dataset *.
COMPUTE j= $casenum-1.
COMPUTE pj = (rj-aj)/rj .
MATCH FILES FILE = *
  /KEEP = j time aj rj pj sj .
* 95% CI limits *.
COMPUTE sum = ((1-pj)/(pj*rj)).
DO IF $casenum GT 1.
- COMPUTE sum=sum+LAG(sum).
- COMPUTE sdlog = SQRT(sum/((LN(sj))**2)).
* 95% Limits using Log(-Log(Sj)) & back transform
* Replace 1.959964 by 2.575829 if 99%CI are wanted *.
- COMPUTE lower = EXP(-EXP(LN(-LN(sj))+1.959964*sdlog)).
- COMPUTE upper = EXP(-EXP(LN(-LN(sj))-1.959964*sdlog)).
END IF.
RESTORE.
* Report *.
FORMAT j TO rj (F8.0) sj pj lower upper (F8.3).
SUMMARIZE
  /TABLES=time sj lower upper
  /FORMAT=LIST NOCASENUM NOTOTAL
  /TITLE='Kaplan-Meier Estimates and Kalbfleisch-Prentice 95% CI'
  /CELLS=NONE.
* Adding survival & CI limits to original dataset *.
MATCH FILES FILE=*
  /KEEP = time sj lower upper.
MATCH FILES
  /FILE='WorkingData2'
  /TABLE=*
  /BY time.
* Adding time=0 survival data (auxiliary file #2) *.
PRESERVE.
SET ERRORS=NONE RESULTS=NONE.
MATRIX.
COMPUTE time=0.
COMPUTE sj=1.
COMPUTE lower=1.
COMPUTE upper=1.
COMPUTE vnames={'time','sj','lower','upper'}.
COMPUTE newdata={time,sj,lower,upper}.
SAVE newdata /OUTFILE='AuxData'/NAMES=vnames.
END MATRIX.
ADD FILES /FILE=*
  /FILE='AuxData'.
SORT CASES BY time(a).
* Filling data for censored cases after the first event *.
DO IF MISSING(sj).
- COMPUTE sj=LAG(sj).
- COMPUTE lower=LAG(lower).
- COMPUTE upper=LAG(upper).
END IF.
RESTORE.
* Survival plot (fully formatted, thanks to ViAnn Beadle) *.
FORMAT sj lower upper (F8.1).
!LET !gdataset=!CONCAT('"','graphdataset','"').
!LET !time=!CONCAT('"','time','"').
!LET !sj=!CONCAT('"','sj','"').
!LET !lower=!CONCAT('"','lower','"').
!LET !upper=!CONCAT('"','upper','"').
!LET !ylabel=!CONCAT('"','Cumulative Survival','"').
!LET !xlabel=!CONCAT('"','Follow-up Time','"').
!LET !title=!CONCAT('"','KM estimate with Kalbfleish-Prentice 95%CI','"').
!LET !px=!CONCAT('"','2px','"').
GGRAPH
   /GRAPHDATASET NAME=!gdataset VARIABLES=time sj lower upper
   MISSING=LISTWISE REPORTMISSING=NO
   /GRAPHSPEC SOURCE=INLINE TEMPLATE="C:\Temp\KPTemplate.sgt".
BEGIN GPL
   SOURCE: s=userSource(id(!gdataset))
   DATA: time=col(source(s), name(!time))
   DATA: sj=col(source(s), name(!sj))
   DATA: lower=col(source(s), name(!lower))
   DATA: upper=col(source(s), name(!upper))
   SCALE: linear(dim(2), include(0))
   GUIDE: axis(dim(1), label(!xlabel))
   GUIDE: axis(dim(2), label(!ylabel), delta(0.1))
   GUIDE: legend(aesthetic(aesthetic.shape.interior), null())
   GUIDE: text.title(label(!title))
   ELEMENT: line(position(smooth.step.left(time*lower)), missing.wings(),
            shape.interior(shape.dash), color(color.black))
   ELEMENT: line(position(smooth.step.left(time*upper)), missing.wings(),
            shape.interior(shape.dash), color(color.black))
   ELEMENT: line(position(smooth.step.left(time*sj)), missing.wings(),
            shape.interior(shape.solid), size(size.!px))
END GPL.
* Tidying up *.
DATASET ACTIVATE OriginalData WINDOW=ASIS.
DATASET CLOSE AuxData.
DATASET CLOSE WorkingData1.
DATASET CLOSE WorkingData2.
!ENDDEFINE.


*****************************************************************
*                     EXAMPLE DATASET                           *
* Table 9.1 Biostatistical Methods in Epidemiology (pp 177-178) *
* Stephen C Newman (2001); JOHN WILEY&SONS                      *
*****************************************************************.
DATA LIST FREE/FuTime Event stage reclevel (4 F8.0).
BEGIN DATA
50 0 1 1 51 1 1 1 51 0 1 1 53 0 1 1 53 0 1 1 54 0 1 1
54 0 1 1 55 0 1 1 56 1 1 1 56 0 1 1 57 0 1 1 60 0 1 1
10 1 1 2 34 1 1 2 34 0 1 2 47 1 1 2 47 1 1 2 49 0 1 2
49 0 1 2 50 0 1 2 50 0 1 2 50 0 1 2 50 0 1 2 50 0 1 2
50 0 1 2 50 0 1 2 51 0 1 2 51 0 1 2 51 0 1 2 51 0 1 2
51 0 1 2 51 0 1 2 52 0 1 2 52 0 1 2 52 0 1 2 52 0 1 2
52 0 1 2 53 0 1 2 53 0 1 2 53 0 1 2 53 0 1 2 53 0 1 2
53 0 1 2 54 0 1 2 54 0 1 2 54 0 1 2 54 0 1 2 54 0 1 2
55 0 1 2 55 0 1 2 56 0 1 2 56 0 1 2 57 0 1 2 57 0 1 2
57 0 1 2 57 0 1 2 57 0 1 2 58 0 1 2 58 0 1 2 58 0 1 2
58 0 1 2 58 0 1 2 59 0 1 2 59 0 1 2 59 0 1 2 59 0 1 2
60 0 1 2 60 0 1 2 60 0 1 2  4 0 2 1  9 1 2 1 13 1 2 1
21 1 2 1 29 1 2 1 29 1 2 1 40 1 2 1 46 1 2 1 49 0 2 1
49 0 2 1 52 0 2 1 52 0 2 1 53 0 2 1 54 0 2 1 55 0 2 1
55 0 2 1 56 0 2 1 57 1 2 1 57 0 2 1 58 0 2 1 58 0 2 1
59 0 2 1 60 0 2 1 11 1 2 2 16 1 2 2 21 1 2 2 23 1 2 2
23 1 2 2 24 1 2 2 33 1 2 2 33 1 2 2 36 1 2 2 36 1 2 2
36 0 2 2 37 1 2 2 45 1 2 2 46 1 2 2 49 0 2 2 49 0 2 2
50 0 2 2 50 0 2 2 50 0 2 2 50 0 2 2 50 0 2 2 50 0 2 2
51 0 2 2 51 0 2 2 51 0 2 2 51 0 2 2 52 0 2 2 52 0 2 2
52 0 2 2 52 0 2 2 52 0 2 2 53 0 2 2 53 0 2 2 53 0 2 2
53 0 2 2 53 0 2 2 54 0 2 2 54 0 2 2 54 0 2 2 54 0 2 2
55 0 2 2 55 0 2 2 55 0 2 2 55 0 2 2 56 0 2 2 56 0 2 2
56 0 2 2 56 0 2 2 56 0 2 2 56 0 2 2 57 0 2 2 57 0 2 2
57 0 2 2 57 0 2 2 58 1 2 2 58 1 2 2 58 0 2 2 58 0 2 2
58 0 2 2 58 0 2 2 58 0 2 2 58 0 2 2 58 0 2 2 58 0 2 2
59 0 2 2 59 0 2 2 59 0 2 2 59 0 2 2 59 0 2 2 60 0 2 2
60 0 2 2 60 0 2 2 60 0 2 2 60 0 2 2 60 0 2 2  9 1 3 1
12 1 3 1 14 1 3 1 15 1 3 1 15 0 3 1 17 1 3 1 21 1 3 1
22 1 3 1 23 1 3 1 23 1 3 1 31 1 3 1 34 1 3 1 35 1 3 1
53 0 3 1 60 0 3 1  7 0 3 2  9 1 3 2 17 1 3 2 21 0 3 2
22 1 3 2 22 1 3 2 34 1 3 2 34 1 3 2 41 1 3 2 49 0 3 2
52 0 3 2 55 1 3 2 56 0 3 2 58 0 3 2 58 0 3 2 59 0 3 2
59 0 3 2
END DATA.
VAR LABEL stage' Tumour Stage'/ reclevel 'Receptor level'
/FuTime 'Survival time (months)' /Event 'Censoring Status'.
VALUE label stage 1'I' 2'II' 3'III'
  /reclevel 1'Low' 2'High' /Event 0'Censored' 1'Event'.

KPSURVIVAL FuTime Event(1).
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: The agony and the ecstasy: Development of complex MATRIX programs.

Kirill Orlov
I started doing such things (WRITEing out syntax) in late 90s when I knew nothing about� SPSSX-L or Raynald and I thought I was the only one in the world who experiments with SPSS syntax. :-)


11.12.2012 13:40, David Marso пишет:
Hanging my head in shame:
I confess to being the original perpetrator of this flavor of dynamic syntax
generation (or maybe I should blame Neila Nessa ).  Some who will remain
nameless have referred to it as a "horrible hack" ;-)
Many people will credit RL for this (or cite his site as example) but that
is historically inaccurate.
One thing which is a crying shame is that all of the SPSS archives before
1996 have been bit bucketed .
Does anyone know why or how 6-10 (I don't know when SPSSX-L first started
but Wikipedia INCORRECTLY cites 1996.  I was posting gems (or what I thought
were at the time) way back in 1991.
-----
DO IF ($CASENUM EQ 1).
WRITE /"spsscode....".
END IF.
EXE.
....
INCLUDE (or use/refer to it somewhere else)...

Reply | Threaded
Open this post in threaded view
|

Re: The agony and the ecstasy: Development of complex MATRIX programs.

David Marso
Administrator
This post was updated on .
In reply to this post by Zuluaga, Juan
I have looked at R and NumPy and in many cases both involve resisting the compulsion to sharpening a spoon to gouge my eyes out!  I am bRamaged beyond repair after prolonged exposure to what I can best describe as R-adioactive code.
"Perhaps IBM/SPSS has realized that they can't compete for that type of user."
Well compare SPSS MATRIX to SAS IML and I say SHAME SPSS/IBM for dropping the ball and pandering to the RSREMCL $trata and completely forgetting the needs of power users (aside from providing PR hooks).


Zuluaga, Juan wrote
David, please take a look at R or NumPy.
IMHO it's easier to write (and read) algorithms in them.
Their growth has been driven by skilled users (people like you) who create packages out of their own code.
Perhaps IBM/SPSS has realized that they can't compete for that type of user.

=====================
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
|

Re: The agony and the ecstasy: Development of complex MATRIX programs.

David Marso
Administrator
In reply to this post by Kirill Orlov
Well then you are clearly a sick man ;-)
--
Kirill Orlov wrote
I started doing such things (WRITEing out syntax) in late 90s when I
knew nothing about  SPSSX-L or Raynald and I thought I was the only one
in the world who experiments with SPSS syntax. :-)


11.12.2012 13:40, David Marso пишет:
> Hanging my head in shame:
> I confess to being the original perpetrator of this flavor of dynamic syntax
> generation (or maybe I should blame Neila Nessa ).  Some who will remain
> nameless have referred to it as a "horrible hack" ;-)
> Many people will credit RL for this (or cite his site as example) but that
> is historically inaccurate.
> One thing which is a crying shame is that all of the SPSS archives before
> 1996 have been bit bucketed .
> Does anyone know why or how 6-10 (I don't know when SPSSX-L first started
> but Wikipedia INCORRECTLY cites 1996.  I was posting gems (or what I thought
> were at the time) way back in 1991.
> -----
> DO IF ($CASENUM EQ 1).
> WRITE /"spsscode....".
> END IF.
> EXE.
> ....
> INCLUDE (or use/refer to it somewhere else)...
>
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: The agony and the ecstasy: Development of complex MATRIX programs.

Maguin, Eugene
In reply to this post by Jon K Peck
David,

Please elaborate on

>> DO IF ($CASENUM EQ 1).
>> WRITE /"spsscode....".
>> END IF.
>> EXE.


Re: Matrix.
Couldn't the (sub)program be characterized as having a Fortran-language set of functions perhaps from IMSL or other source of known code wrapped inside of a command processor/interpreter/error checker shell probably written in a language other than fortran.

Gene Maguin


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso
Sent: Tuesday, December 11, 2012 5:11 AM
To: [hidden email]
Subject: Re: The agony and the ecstasy: Development of complex MATRIX programs.

Well then you are clearly a sick man ;-)
--

Kirill Orlov wrote

> I started doing such things (WRITEing out syntax) in late 90s when I
> knew nothing about  SPSSX-L or Raynald and I thought I was the only
> one in the world who experiments with SPSS syntax. :-)
>
>
> 11.12.2012 13:40, David Marso пишет:
>> Hanging my head in shame:
>> I confess to being the original perpetrator of this flavor of dynamic
>> syntax generation (or maybe I should blame Neila Nessa ).  Some who
>> will remain nameless have referred to it as a "horrible hack" ;-)
>> Many people will credit RL for this (or cite his site as example) but
>> that is historically inaccurate.
>> One thing which is a crying shame is that all of the SPSS archives
>> before
>> 1996 have been bit bucketed .
>> Does anyone know why or how 6-10 (I don't know when SPSSX-L first
>> started but Wikipedia INCORRECTLY cites 1996.  I was posting gems (or
>> what I thought were at the time) way back in 1991.
>> -----
>> DO IF ($CASENUM EQ 1).
>> WRITE /"spsscode....".
>> END IF.
>> EXE.
>> ....
>> INCLUDE (or use/refer to it somewhere else)...
>>





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/The-agony-and-the-ecstacy-Development-of-complex-MATRIX-programs-tp5716810p5716867.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
Reply | Threaded
Open this post in threaded view
|

Re: The agony and the ecstasy: Development of complex MATRIX programs.

David Marso
Administrator
Second question first:
"Re: Matrix.
Couldn't the (sub)program be characterized as having a Fortran-language set of functions perhaps from IMSL or other source of known code wrapped inside of a command processor/interpreter/error checker shell probably written in a language other than fortran."

It would seem that all of the source already exists within the SPSS code itself.  Someone would need to harvest it and wrap it then make it callable from MATRIX.  I don't see what the development issues are aside from the innards of much of SPSS are probably pretty scary from a modularization perspective.

First question: "Please elaborate on

>> DO IF ($CASENUM EQ 1).
>> WRITE /"spsscode....".
>> END IF.
>> EXE."
Please no, do I really have to? ;-((
-
<SHAME >
For a classic example peer inside the cancorr.sps syntax .
Unless that has been modified since my circa 1996 rewrite there lies festering an ugly mess which I am not particularly proud of perpetrating.  The problem which was being solved here was running out of memory when scoring large data sets (MATRIX was/is not really a happy camper when dealing with 100,000 cases and 100-200 variables as it requires the data to be in memory (yes there were some savage DU's who actually complained about this)).  Basically to cut to the chase... The following brilliant brain fart actually made it into distribution and AFAIK may still be lurking in the void of developmental inertia (if it ain't broken down fix it and/or eeeeewwww, I'm not touching that (instinctive recoil of any sane maintainence programmer)).
---
<horrible mess>
SELECT IF $CASENUM=1.
DO REPEAT V=!SET1.
COMPUTE V=1.
END REPEAT.
DO REPEAT V=!SET2.
COMPUTE V=2.
END REPEAT.
STRING VARNAME (A8).
COMPUTE VARNAME='SET_NUM'.
FLIP VARIABLES !SET1 !SET2 / NEWNAMES=VARNAME .
COMPUTE VARSEQ=1.
SPLIT FILE BY SET_NUM.
CREATE VARSEQ=CSUM(VARSEQ).
SAVE OUTFILE 'CC_NAMES.SAV'.
GET FILE 'CC__SIZE.SAV' .

*---------------------------------------------------------------------------.
* Set up required information to create compute statements for scoring.
*---------------------------------------------------------------------------.

WRITE OUTFILE 'CC__AB.INC'
   /'STRING @NMA001 TO @NMA',COL1 (N3), ' (A8)'
   /'       @NMB001 TO @NMB',COL2 (N3), ' (A8)'
   /'VECTOR @NMA= @NMA001 TO @NMA',COL1 (N3)
   /'       @NMB= @NMB001 TO @NMB',COL2 (N3)
   /'COMPUTE N_A='COL1 (N3)
   /'COMPUTE N_B='COL2 (N3)
   /'IF (SET_NUM=1) @NMA(VARSEQ)=CASE_LBL'
   /'IF (SET_NUM=2) @NMB(VARSEQ)=CASE_LBL'
   /'COMPUTE @=1'
   /'AGGREGATE OUTFILE "CC__SPRD.SAV" / BREAK @'
   / ' / N_A=MAX(N_A) / N_B=MAX(N_B)'
   / ' / @NMA001 TO @NMA',COL1 (N3) '=MAX (@NMA001 TO @NMA',COL1 (N3),')'
   / ' / @NMB001 TO @NMB',COL2 (N3) '=MAX (@NMB001 TO @NMB',COL2 (N3),')'
   / 'GET FILE "CC__AB.SAV"'
   / 'COMPUTE @=1'
   / 'MATCH FILES FILE * / TABLE "CC__SPRD.SAV"/BY @'
   / 'VECTOR @NMA= @NMA001 TO @NMA',COL1 (N3)
   / '       @NMB= @NMB001 TO @NMB',COL2 (N3)
   / '       COEF= COL1 TO @'.
EXECUTE.

GET FILE 'CC_NAMES.SAV'.
INCLUDE FILE 'CC__AB.INC'.
SET PRINTBACK OFF.

*---------------------------------------------------------------------------.
* Write out the compute statements for scoring.
*---------------------------------------------------------------------------.

STRING @SCNM@ (A8).
STRING @OLDNM@ (A8).
COMPUTE @SCNM@=CONCAT('S1_CV',STRING($CASENUM,N3)).
WRITE OUTFILE 'CC__.INC' /'COMPUTE ',@SCNM@ ,'= 0'.
LOOP CC@@@ = 1 TO N_A.
COMPUTE @OLDNM@=@NMA(CC@@@).
COMPUTE @COEF@ =COEF(CC@@@).
WRITE OUTFILE 'CC__.INC' / ' +',@COEF@ (comma18.16),' * ',@OLDNM@ .
END LOOP.
COMPUTE @SCNM@=CONCAT('S2_CV',STRING($CASENUM,N3)).
WRITE OUTFILE 'CC__.INC' /'COMPUTE ',@SCNM@ ,'= 0'.
LOOP CC@@@=1 TO N_B.
COMPUTE @OLDNM@=@NMB(CC@@@).
COMPUTE @COEF@ =COEF(CC@@@+N_A).
WRITE OUTFILE 'CC__.INC' / ' +',@COEF@ (comma18.16),' * ',@OLDNM@ .
END LOOP.
EXECUTE.

*---------------------------------------------------------------------------.
* Get the original data and run the scoring program.
*---------------------------------------------------------------------------.

GET FILE 'cc__tmp1.sav'.
INCLUDE FILE 'CC__.INC' .

</horrible mess>
GACK!!!!
So if you are still standing after having your brain assaulted by that horrible hack ...You probably need a cup of coffee or a shot of something stronger.  Maybe a mid morning nap?  Perhaps a cranial enema? ;-)
</SHAME>
Now you have done it.  I feel really dirty ;-)!!!
--

Maguin, Eugene wrote
David,

Please elaborate on

>> DO IF ($CASENUM EQ 1).
>> WRITE /"spsscode....".
>> END IF.
>> EXE.


Re: Matrix.
Couldn't the (sub)program be characterized as having a Fortran-language set of functions perhaps from IMSL or other source of known code wrapped inside of a command processor/interpreter/error checker shell probably written in a language other than fortran.

Gene Maguin


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso
Sent: Tuesday, December 11, 2012 5:11 AM
To: [hidden email]
Subject: Re: The agony and the ecstasy: Development of complex MATRIX programs.

Well then you are clearly a sick man ;-)
--

Kirill Orlov wrote
> I started doing such things (WRITEing out syntax) in late 90s when I
> knew nothing about  SPSSX-L or Raynald and I thought I was the only
> one in the world who experiments with SPSS syntax. :-)
>
>
> 11.12.2012 13:40, David Marso пишет:
>> Hanging my head in shame:
>> I confess to being the original perpetrator of this flavor of dynamic
>> syntax generation (or maybe I should blame Neila Nessa ).  Some who
>> will remain nameless have referred to it as a "horrible hack" ;-)
>> Many people will credit RL for this (or cite his site as example) but
>> that is historically inaccurate.
>> One thing which is a crying shame is that all of the SPSS archives
>> before
>> 1996 have been bit bucketed .
>> Does anyone know why or how 6-10 (I don't know when SPSSX-L first
>> started but Wikipedia INCORRECTLY cites 1996.  I was posting gems (or
>> what I thought were at the time) way back in 1991.
>> -----
>> DO IF ($CASENUM EQ 1).
>> WRITE /"spsscode....".
>> END IF.
>> EXE.
>> ....
>> INCLUDE (or use/refer to it somewhere else)...
>>





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/The-agony-and-the-ecstacy-Development-of-complex-MATRIX-programs-tp5716810p5716867.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?"
12