LARGE output file to pdf

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

LARGE output file to pdf

Jeff Mather-2
Hi,
I'm running syntax that generates 2 output files containing 6 and 21 bar
charts.  The output for the second file (n=21 charts)is huge, 160 MB. I
have Acrobat distiller to save the file as a .pdf, but it takes forever to
open the file.  Is there a way to script this to save as a .pdf?

Thanks for any help.

Jeff

GET DATA /TYPE=ODBC /CONNECT=
'DSN=LAB;UID=lab_user;PWD=''x/q-s6V#U"^#u.o'
 /SQL =
 'SELECT  "T12"."visitnum" AS "visitnum",  "T12"."seq4c" AS "seq4c",  '
  '"T12"."seq5" AS "seq5",  "T12"."obrdate" AS "obrdate",  "T12"."YYYY" AS '
  '"YYYY",  "T12"."MM" AS "MM",  "T12"."DD" AS "DD",  "T12"."seq12" AS '
  '"seq12" FROM  "LAB"."dbo"."vw_Glucose" "T12"'
 .
VARIABLE LABELS  visitnum "visitnum" seq4c "seq4c" seq5 "seq5" obrdate
  "obrdate" YYYY "YYYY" MM "MM" DD "DD" seq12 "seq12".
CACHE.
EXECUTE.
COMPUTE Gluc = NUMBER(seq5,f8) .
EXECUTE .
AUTORECODE
  VARIABLES=seq4c  /INTO test
  /PRINT.


COMPUTE unit_1 = INDEX(seq12,'^') .
EXECUTE .


STRING unit_2 (A8).
COMPUTE unit_2 = SUBSTR(seq12,1,unit_1-1) .
EXECUTE .
*AUTORECODE
 * VARIABLES=unit_2  /INTO unit
  */PRINT.


RECODE
  unit_2
  ('B10E'=7)  ('B10I'=1)  ('B10S'=8)  ('B11E'=9)  ('B7I'=2)  ('B7E'=10)
  ('B5W'=11)  ('B11S'=12)  ('B11I'=3)  ('B7S'=13)  ('B8'=14)  ('B8E'=15)
  ('B9E'=16)  ('B9I'=4)  ('B9S'=17)  ('BW2R'=18)  ('C10'=19)  ('C12'=20)
  ('C8'=21)  ('C9EI'=5)  ('C9WI'=6)  ('CB4'=22)  ('CB5R'=23)  ('CB5'=24)
  ('CB6'=25)  ('JB4'=26)  ('N10'=27)  ('N11'=28)  ('N12'=29)  ('N9'=30)
  ('N9S'=31)  INTO  unit .
VARIABLE LABELS unit 'Unit'.
EXECUTE .

*Define Variable Properties.
*unit.
VARIABLE LEVEL unit  (Nominal).
FORMATS unit (F8.0).
VALUE LABELS  unit
     7  'B10E'
     1  'B10I'
     8  'B10S'
     9  'B11E'
     3  'B11I'
   12  'B11S'
   11  'B5W'
   10  'B7E'
     2  'B7I'
   13  'B7S'
   14  'B8'
   15  'B8E'
   16  'B9E'
     4  'B9I'
   17  'B9S'
   18  'BW2R'
   19  'C10'
   20  'C12'
   21  'C8'
     5  'C9EI'
     6  'C9WI'
   22  'CB4'
   24  'CB5'
   23  'CB5R'
   25  'CB6'
   26  'JB4'
   27  'N10'
   28  'N11'
   29  'N12'
   30  'N9'
   31  'N9S'  .
EXECUTE.

RECODE
  unit
  (1 thru 6=1)  INTO  group .
EXECUTE .


RECODE
  unit
  (7 thru 31=2)  INTO  group .
EXECUTE .

*Define Variable Properties.
*group.
VARIABLE LEVEL group  (Nominal).
VARIABLE LABELS group  'Group'.
VALUE LABELS  group
     1  'ICU'
     2  'Other'  .
EXECUTE.

RECODE
  gluc
  (0 thru 40=1)  (41 thru 65=2)  (66 thru 110=3)  (111 thru 150=4)  (151
thru
  180=5)  (181 thru 200=6)  (201 thru 250=7)  (250 thru 300=8)  (301 thru
  Highest=9)  INTO  gluCat .
VARIABLE LABELS gluCat 'Glucose Categories'.
EXECUTE .
*Define Variable Properties.
*glucat.
VARIABLE LEVEL glucat  (Ordinal).
VALUE LABELS  glucat
     1  '0-40'
     2  '41-65'
     3  '66-110'
     4  '111-150'
     5  '151-180'
     6  '181-200'
     7  '201-250'
     8  '250-300'
     9  '>300'  .
EXECUTE.

SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose.sav'
 /COMPRESSED.


FILTER OFF.
USE ALL.
SELECT IF(group = 1).
EXECUTE .

SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose_ICU.sav'
 /COMPRESSED.

SET MPRINT=yes /PRINTBACK=yes.

*MACRO STARTS.
*///////////////////////////////////////////////////////////////////////////
/////////////.
DEFINE !GluChrt (UNITS= !TOKENS(1))

!DO !I = 1 !TO 6.

*6 = # of units reported - adjust as required.


USE ALL.
COMPUTE filter_$=(unit = !I).
VARIABLE LABEL filter_$ 'unit = 1 (FILTER)'.
VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE .

IGRAPH /VIEWNAME='Bar Chart' /X1 = VAR(glucat) TYPE = CATEGORICAL /Y = $pct
 /COLOR = VAR(unit) TYPE = CATEGORICAL CLUSTER /COORDINATE = VERTICAL
  /X1LENGTH=6.0 /YLENGTH=4.0 /X2LENGTH=3.0
 /CHARTLOOK='C:\Program Files\SPSS\Looks\Chalkboard.clo' /CATORDER VAR
(glucat)
  (ASCENDING VALUES OMITEMPTY) /BAR KEY=ON LABEL INSIDE N  SHAPE = RECTANGLE
  BASELINE = AUTO.


FILTER OFF.
USE ALL.
EXECUTE .

!DOEND.
!ENDDEFINE.
*///////////////////////////////////////////////////////////////////////////
/////////////.

WRITE OUTFILE = 'C:\TEMP\SYNTAX.SPS'  /'!GluChrt UNIT='UNIT.
EXECUTE.

INCLUDE 'C:\TEMP\SYNTAX.SPS'.

* Define a macro which will yield the current Date.
String #CDate(A9).
COMPUTE #CDate=$Date.
Do If $casenum=1.
Write OUTFILE 'c:\temp\temp.sps' /"DEFINE !date()'"#cdate"'!ENDDEFINE.".
End If.
Execute.
* Run the macro.
INCLUDE 'c:\temp\temp.sps'.

**SAVE OUTFILE='c:\temp\example1_' + !date + '.sav'.

SCRIPT file="G:\Dbases\GlycemicControl\saveOutAs.sbs" /
("G:\Dbases\GlycemicControl\Glucose_ICU.spo") .
*---------------------------------------------------Do same for group = 2---
----------------------------------------------------------------------------
-----.

GET
  FILE='G:\Dbases\GlycemicControl\Glucose.sav'.


FILTER OFF.
USE ALL.
SELECT IF(group = 2).
EXECUTE .

SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose_OtherFloors.sav'
 /COMPRESSED.

SET MPRINT=yes /PRINTBACK=yes.

*MACRO STARTS.
*///////////////////////////////////////////////////////////////////////////
/////////////.
DEFINE !GluChrt (UNITS= !TOKENS(1))

!DO !I = 7 !TO 31.

USE ALL.
COMPUTE filter_$=(unit = !I).
VARIABLE LABEL filter_$ 'unit = 1 (FILTER)'.
VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE .

IGRAPH /VIEWNAME='Bar Chart' /X1 = VAR(glucat) TYPE = CATEGORICAL /Y = $pct
 /COLOR = VAR(unit) TYPE = CATEGORICAL CLUSTER /COORDINATE = VERTICAL
  /X1LENGTH=6.0 /YLENGTH=4.0 /X2LENGTH=3.0
 /CHARTLOOK='C:\Program Files\SPSS\Looks\Chalkboard.clo' /CATORDER VAR
(glucat)
  (ASCENDING VALUES OMITEMPTY) /BAR KEY=ON LABEL INSIDE N  SHAPE = RECTANGLE
  BASELINE = AUTO.


FILTER OFF.
USE ALL.
EXECUTE .

!DOEND.
!ENDDEFINE.
*///////////////////////////////////////////////////////////////////////////
/////////////.

WRITE OUTFILE = 'C:\TEMP\SYNTAX.SPS'  /'!GluChrt UNIT='UNIT.
EXECUTE.

INCLUDE 'C:\TEMP\SYNTAX.SPS'.

SCRIPT file="G:\Dbases\GlycemicControl\saveOutAs.sbs" /
("G:\Dbases\GlycemicControl\Glucose_OtherFloors.spo") .


GET DATA /TYPE=ODBC /CONNECT=
'DSN=LAB;UID=lab_user;PWD=''x/q-s6V#U"^#u.o'
 /SQL =
 'SELECT  "T12"."visitnum" AS "visitnum",  "T12"."seq4c" AS "seq4c",  '
  '"T12"."seq5" AS "seq5",  "T12"."obrdate" AS "obrdate",  "T12"."YYYY" AS '
  '"YYYY",  "T12"."MM" AS "MM",  "T12"."DD" AS "DD",  "T12"."seq12" AS '
  '"seq12" FROM  "LAB"."dbo"."vw_Glucose" "T12"'
 .
VARIABLE LABELS  visitnum "visitnum" seq4c "seq4c" seq5 "seq5" obrdate
  "obrdate" YYYY "YYYY" MM "MM" DD "DD" seq12 "seq12".
CACHE.
EXECUTE.
COMPUTE Gluc = NUMBER(seq5,f8) .
EXECUTE .
AUTORECODE
  VARIABLES=seq4c  /INTO test
  /PRINT.


COMPUTE unit_1 = INDEX(seq12,'^') .
EXECUTE .


STRING unit_2 (A8).
COMPUTE unit_2 = SUBSTR(seq12,1,unit_1-1) .
EXECUTE .
*AUTORECODE
 * VARIABLES=unit_2  /INTO unit
  */PRINT.


RECODE
  unit_2
  ('B10E'=7)  ('B10I'=1)  ('B10S'=8)  ('B11E'=9)  ('B7I'=2)  ('B7E'=10)
  ('B5W'=11)  ('B11S'=12)  ('B11I'=3)  ('B7S'=13)  ('B8'=14)  ('B8E'=15)
  ('B9E'=16)  ('B9I'=4)  ('B9S'=17)  ('BW2R'=18)  ('C10'=19)  ('C12'=20)
  ('C8'=21)  ('C9EI'=5)  ('C9WI'=6)  ('CB4'=22)  ('CB5R'=23)  ('CB5'=24)
  ('CB6'=25)  ('JB4'=26)  ('N10'=27)  ('N11'=28)  ('N12'=29)  ('N9'=30)
  ('N9S'=31)  INTO  unit .
VARIABLE LABELS unit 'Unit'.
EXECUTE .

*Define Variable Properties.
*unit.
VARIABLE LEVEL unit  (Nominal).
FORMATS unit (F8.0).
VALUE LABELS  unit
     7  'B10E'
     1  'B10I'
     8  'B10S'
     9  'B11E'
     3  'B11I'
   12  'B11S'
   11  'B5W'
   10  'B7E'
     2  'B7I'
   13  'B7S'
   14  'B8'
   15  'B8E'
   16  'B9E'
     4  'B9I'
   17  'B9S'
   18  'BW2R'
   19  'C10'
   20  'C12'
   21  'C8'
     5  'C9EI'
     6  'C9WI'
   22  'CB4'
   24  'CB5'
   23  'CB5R'
   25  'CB6'
   26  'JB4'
   27  'N10'
   28  'N11'
   29  'N12'
   30  'N9'
   31  'N9S'  .
EXECUTE.

RECODE
  unit
  (1 thru 6=1)  INTO  group .
EXECUTE .


RECODE
  unit
  (7 thru 31=2)  INTO  group .
EXECUTE .

*Define Variable Properties.
*group.
VARIABLE LEVEL group  (Nominal).
VARIABLE LABELS group  'Group'.
VALUE LABELS  group
     1  'ICU'
     2  'Other'  .
EXECUTE.

RECODE
  gluc
  (0 thru 40=1)  (41 thru 65=2)  (66 thru 110=3)  (111 thru 150=4)  (151
thru
  180=5)  (181 thru 200=6)  (201 thru 250=7)  (250 thru 300=8)  (301 thru
  Highest=9)  INTO  gluCat .
VARIABLE LABELS gluCat 'Glucose Categories'.
EXECUTE .
*Define Variable Properties.
*glucat.
VARIABLE LEVEL glucat  (Ordinal).
VALUE LABELS  glucat
     1  '0-40'
     2  '41-65'
     3  '66-110'
     4  '111-150'
     5  '151-180'
     6  '181-200'
     7  '201-250'
     8  '250-300'
     9  '>300'  .
EXECUTE.

SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose.sav'
 /COMPRESSED.


FILTER OFF.
USE ALL.
SELECT IF(group = 1).
EXECUTE .

SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose_ICU.sav'
 /COMPRESSED.

SET MPRINT=yes /PRINTBACK=yes.

*MACRO STARTS.
*///////////////////////////////////////////////////////////////////////////
/////////////.
DEFINE !GluChrt (UNITS= !TOKENS(1))

!DO !I = 1 !TO 6.

*6 = # of units reported - adjust as required.


USE ALL.
COMPUTE filter_$=(unit = !I).
VARIABLE LABEL filter_$ 'unit = 1 (FILTER)'.
VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE .

IGRAPH /VIEWNAME='Bar Chart' /X1 = VAR(glucat) TYPE = CATEGORICAL /Y = $pct
 /COLOR = VAR(unit) TYPE = CATEGORICAL CLUSTER /COORDINATE = VERTICAL
  /X1LENGTH=6.0 /YLENGTH=4.0 /X2LENGTH=3.0
 /CHARTLOOK='C:\Program Files\SPSS\Looks\Chalkboard.clo' /CATORDER VAR
(glucat)
  (ASCENDING VALUES OMITEMPTY) /BAR KEY=ON LABEL INSIDE N  SHAPE = RECTANGLE
  BASELINE = AUTO.


FILTER OFF.
USE ALL.
EXECUTE .

!DOEND.
!ENDDEFINE.
*///////////////////////////////////////////////////////////////////////////
/////////////.

WRITE OUTFILE = 'C:\TEMP\SYNTAX.SPS'  /'!GluChrt UNIT='UNIT.
EXECUTE.

INCLUDE 'C:\TEMP\SYNTAX.SPS'.

* Define a macro which will yield the current Date.
String #CDate(A9).
COMPUTE #CDate=$Date.
Do If $casenum=1.
Write OUTFILE 'c:\temp\temp.sps' /"DEFINE !date()'"#cdate"'!ENDDEFINE.".
End If.
Execute.
* Run the macro.
INCLUDE 'c:\temp\temp.sps'.

**SAVE OUTFILE='c:\temp\example1_' + !date + '.sav'.

SCRIPT file="G:\Dbases\GlycemicControl\saveOutAs.sbs" /
("G:\Dbases\GlycemicControl\Glucose_ICU.spo") .
*---------------------------------------------------Do same for group = 2---
----------------------------------------------------------------------------
-----.

GET
  FILE='G:\Dbases\GlycemicControl\Glucose.sav'.


FILTER OFF.
USE ALL.
SELECT IF(group = 2).
EXECUTE .

SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose_OtherFloors.sav'
 /COMPRESSED.

SET MPRINT=yes /PRINTBACK=yes.

*MACRO STARTS.
*///////////////////////////////////////////////////////////////////////////
/////////////.
DEFINE !GluChrt (UNITS= !TOKENS(1))

!DO !I = 7 !TO 31.

USE ALL.
COMPUTE filter_$=(unit = !I).
VARIABLE LABEL filter_$ 'unit = 1 (FILTER)'.
VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE .

IGRAPH /VIEWNAME='Bar Chart' /X1 = VAR(glucat) TYPE = CATEGORICAL /Y = $pct
 /COLOR = VAR(unit) TYPE = CATEGORICAL CLUSTER /COORDINATE = VERTICAL
  /X1LENGTH=6.0 /YLENGTH=4.0 /X2LENGTH=3.0
 /CHARTLOOK='C:\Program Files\SPSS\Looks\Chalkboard.clo' /CATORDER VAR
(glucat)
  (ASCENDING VALUES OMITEMPTY) /BAR KEY=ON LABEL INSIDE N  SHAPE = RECTANGLE
  BASELINE = AUTO.


FILTER OFF.
USE ALL.
EXECUTE .

!DOEND.
!ENDDEFINE.
*///////////////////////////////////////////////////////////////////////////
/////////////.

WRITE OUTFILE = 'C:\TEMP\SYNTAX.SPS'  /'!GluChrt UNIT='UNIT.
EXECUTE.

INCLUDE 'C:\TEMP\SYNTAX.SPS'.

SCRIPT file="G:\Dbases\GlycemicControl\saveOutAs.sbs" /
("G:\Dbases\GlycemicControl\Glucose_OtherFloors.spo") .


GET DATA /TYPE=ODBC /CONNECT=
'DSN=LAB;UID=lab_user;PWD=''x/q-s6V#U"^#u.o'
 /SQL =
 'SELECT  "T12"."visitnum" AS "visitnum",  "T12"."seq4c" AS "seq4c",  '
  '"T12"."seq5" AS "seq5",  "T12"."obrdate" AS "obrdate",  "T12"."YYYY" AS '
  '"YYYY",  "T12"."MM" AS "MM",  "T12"."DD" AS "DD",  "T12"."seq12" AS '
  '"seq12" FROM  "LAB"."dbo"."vw_Glucose" "T12"'
 .
VARIABLE LABELS  visitnum "visitnum" seq4c "seq4c" seq5 "seq5" obrdate
  "obrdate" YYYY "YYYY" MM "MM" DD "DD" seq12 "seq12".
CACHE.
EXECUTE.
COMPUTE Gluc = NUMBER(seq5,f8) .
EXECUTE .
AUTORECODE
  VARIABLES=seq4c  /INTO test
  /PRINT.


COMPUTE unit_1 = INDEX(seq12,'^') .
EXECUTE .


STRING unit_2 (A8).
COMPUTE unit_2 = SUBSTR(seq12,1,unit_1-1) .
EXECUTE .
*AUTORECODE
 * VARIABLES=unit_2  /INTO unit
  */PRINT.


RECODE
  unit_2
  ('B10E'=7)  ('B10I'=1)  ('B10S'=8)  ('B11E'=9)  ('B7I'=2)  ('B7E'=10)
  ('B5W'=11)  ('B11S'=12)  ('B11I'=3)  ('B7S'=13)  ('B8'=14)  ('B8E'=15)
  ('B9E'=16)  ('B9I'=4)  ('B9S'=17)  ('BW2R'=18)  ('C10'=19)  ('C12'=20)
  ('C8'=21)  ('C9EI'=5)  ('C9WI'=6)  ('CB4'=22)  ('CB5R'=23)  ('CB5'=24)
  ('CB6'=25)  ('JB4'=26)  ('N10'=27)  ('N11'=28)  ('N12'=29)  ('N9'=30)
  ('N9S'=31)  INTO  unit .
VARIABLE LABELS unit 'Unit'.
EXECUTE .

*Define Variable Properties.
*unit.
VARIABLE LEVEL unit  (Nominal).
FORMATS unit (F8.0).
VALUE LABELS  unit
     7  'B10E'
     1  'B10I'
     8  'B10S'
     9  'B11E'
     3  'B11I'
   12  'B11S'
   11  'B5W'
   10  'B7E'
     2  'B7I'
   13  'B7S'
   14  'B8'
   15  'B8E'
   16  'B9E'
     4  'B9I'
   17  'B9S'
   18  'BW2R'
   19  'C10'
   20  'C12'
   21  'C8'
     5  'C9EI'
     6  'C9WI'
   22  'CB4'
   24  'CB5'
   23  'CB5R'
   25  'CB6'
   26  'JB4'
   27  'N10'
   28  'N11'
   29  'N12'
   30  'N9'
   31  'N9S'  .
EXECUTE.

RECODE
  unit
  (1 thru 6=1)  INTO  group .
EXECUTE .


RECODE
  unit
  (7 thru 31=2)  INTO  group .
EXECUTE .

*Define Variable Properties.
*group.
VARIABLE LEVEL group  (Nominal).
VARIABLE LABELS group  'Group'.
VALUE LABELS  group
     1  'ICU'
     2  'Other'  .
EXECUTE.

RECODE
  gluc
  (0 thru 40=1)  (41 thru 65=2)  (66 thru 110=3)  (111 thru 150=4)  (151
thru
  180=5)  (181 thru 200=6)  (201 thru 250=7)  (250 thru 300=8)  (301 thru
  Highest=9)  INTO  gluCat .
VARIABLE LABELS gluCat 'Glucose Categories'.
EXECUTE .
*Define Variable Properties.
*glucat.
VARIABLE LEVEL glucat  (Ordinal).
VALUE LABELS  glucat
     1  '0-40'
     2  '41-65'
     3  '66-110'
     4  '111-150'
     5  '151-180'
     6  '181-200'
     7  '201-250'
     8  '250-300'
     9  '>300'  .
EXECUTE.

SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose.sav'
 /COMPRESSED.


FILTER OFF.
USE ALL.
SELECT IF(group = 1).
EXECUTE .

SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose_ICU.sav'
 /COMPRESSED.

SET MPRINT=yes /PRINTBACK=yes.

*MACRO STARTS.
*///////////////////////////////////////////////////////////////////////////
/////////////.
DEFINE !GluChrt (UNITS= !TOKENS(1))

!DO !I = 1 !TO 6.

*6 = # of units reported - adjust as required.


USE ALL.
COMPUTE filter_$=(unit = !I).
VARIABLE LABEL filter_$ 'unit = 1 (FILTER)'.
VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE .

IGRAPH /VIEWNAME='Bar Chart' /X1 = VAR(glucat) TYPE = CATEGORICAL /Y = $pct
 /COLOR = VAR(unit) TYPE = CATEGORICAL CLUSTER /COORDINATE = VERTICAL
  /X1LENGTH=6.0 /YLENGTH=4.0 /X2LENGTH=3.0
 /CHARTLOOK='C:\Program Files\SPSS\Looks\Chalkboard.clo' /CATORDER VAR
(glucat)
  (ASCENDING VALUES OMITEMPTY) /BAR KEY=ON LABEL INSIDE N  SHAPE = RECTANGLE
  BASELINE = AUTO.


FILTER OFF.
USE ALL.
EXECUTE .

!DOEND.
!ENDDEFINE.
*///////////////////////////////////////////////////////////////////////////
/////////////.

WRITE OUTFILE = 'C:\TEMP\SYNTAX.SPS'  /'!GluChrt UNIT='UNIT.
EXECUTE.

INCLUDE 'C:\TEMP\SYNTAX.SPS'.

* Define a macro which will yield the current Date.
String #CDate(A9).
COMPUTE #CDate=$Date.
Do If $casenum=1.
Write OUTFILE 'c:\temp\temp.sps' /"DEFINE !date()'"#cdate"'!ENDDEFINE.".
End If.
Execute.
* Run the macro.
INCLUDE 'c:\temp\temp.sps'.

**SAVE OUTFILE='c:\temp\example1_' + !date + '.sav'.

SCRIPT file="G:\Dbases\GlycemicControl\saveOutAs.sbs" /
("G:\Dbases\GlycemicControl\Glucose_ICU.spo") .
*---------------------------------------------------Do same for group = 2---
----------------------------------------------------------------------------
-----.

GET
  FILE='G:\Dbases\GlycemicControl\Glucose.sav'.


FILTER OFF.
USE ALL.
SELECT IF(group = 2).
EXECUTE .

SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose_OtherFloors.sav'
 /COMPRESSED.

SET MPRINT=yes /PRINTBACK=yes.

*MACRO STARTS.
*///////////////////////////////////////////////////////////////////////////
/////////////.
DEFINE !GluChrt (UNITS= !TOKENS(1))

!DO !I = 7 !TO 31.

USE ALL.
COMPUTE filter_$=(unit = !I).
VARIABLE LABEL filter_$ 'unit = 1 (FILTER)'.
VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE .

IGRAPH /VIEWNAME='Bar Chart' /X1 = VAR(glucat) TYPE = CATEGORICAL /Y = $pct
 /COLOR = VAR(unit) TYPE = CATEGORICAL CLUSTER /COORDINATE = VERTICAL
  /X1LENGTH=6.0 /YLENGTH=4.0 /X2LENGTH=3.0
 /CHARTLOOK='C:\Program Files\SPSS\Looks\Chalkboard.clo' /CATORDER VAR
(glucat)
  (ASCENDING VALUES OMITEMPTY) /BAR KEY=ON LABEL INSIDE N  SHAPE = RECTANGLE
  BASELINE = AUTO.


FILTER OFF.
USE ALL.
EXECUTE .

!DOEND.
!ENDDEFINE.
*///////////////////////////////////////////////////////////////////////////
/////////////.

WRITE OUTFILE = 'C:\TEMP\SYNTAX.SPS'  /'!GluChrt UNIT='UNIT.
EXECUTE.

INCLUDE 'C:\TEMP\SYNTAX.SPS'.

SCRIPT file="G:\Dbases\GlycemicControl\saveOutAs.sbs" /
("G:\Dbases\GlycemicControl\Glucose_OtherFloors.spo") .
Reply | Threaded
Open this post in threaded view
|

Re: LARGE output file to pdf

Keith McCormick
Hi Jeff,

15.0 is not out, but the .pdf on the web site and other annoucements
http://www.spss.com/events/event.cfm?E_ID=1768&Country=US indicate
that exporting directly to .pdf is coming.  There is no command at the
moment, and I don't know what syntax support the new feature will
have.

Best, Keith

www.keithmccormick.com

On 9/8/06, Jeff <[hidden email]> wrote:

> Hi,
> I'm running syntax that generates 2 output files containing 6 and 21 bar
> charts.  The output for the second file (n=21 charts)is huge, 160 MB. I
> have Acrobat distiller to save the file as a .pdf, but it takes forever to
> open the file.  Is there a way to script this to save as a .pdf?
>
> Thanks for any help.
>
> Jeff
>
> GET DATA /TYPE=ODBC /CONNECT=
> 'DSN=LAB;UID=lab_user;PWD=''x/q-s6V#U"^#u.o'
>  /SQL =
>  'SELECT  "T12"."visitnum" AS "visitnum",  "T12"."seq4c" AS "seq4c",  '
>  '"T12"."seq5" AS "seq5",  "T12"."obrdate" AS "obrdate",  "T12"."YYYY" AS '
>  '"YYYY",  "T12"."MM" AS "MM",  "T12"."DD" AS "DD",  "T12"."seq12" AS '
>  '"seq12" FROM  "LAB"."dbo"."vw_Glucose" "T12"'
>  .
> VARIABLE LABELS  visitnum "visitnum" seq4c "seq4c" seq5 "seq5" obrdate
>  "obrdate" YYYY "YYYY" MM "MM" DD "DD" seq12 "seq12".
> CACHE.
> EXECUTE.
> COMPUTE Gluc = NUMBER(seq5,f8) .
> EXECUTE .
> AUTORECODE
>  VARIABLES=seq4c  /INTO test
>  /PRINT.
>
>
> COMPUTE unit_1 = INDEX(seq12,'^') .
> EXECUTE .
>
>
> STRING unit_2 (A8).
> COMPUTE unit_2 = SUBSTR(seq12,1,unit_1-1) .
> EXECUTE .
> *AUTORECODE
>  * VARIABLES=unit_2  /INTO unit
>  */PRINT.
>
>
> RECODE
>  unit_2
>  ('B10E'=7)  ('B10I'=1)  ('B10S'=8)  ('B11E'=9)  ('B7I'=2)  ('B7E'=10)
>  ('B5W'=11)  ('B11S'=12)  ('B11I'=3)  ('B7S'=13)  ('B8'=14)  ('B8E'=15)
>  ('B9E'=16)  ('B9I'=4)  ('B9S'=17)  ('BW2R'=18)  ('C10'=19)  ('C12'=20)
>  ('C8'=21)  ('C9EI'=5)  ('C9WI'=6)  ('CB4'=22)  ('CB5R'=23)  ('CB5'=24)
>  ('CB6'=25)  ('JB4'=26)  ('N10'=27)  ('N11'=28)  ('N12'=29)  ('N9'=30)
>  ('N9S'=31)  INTO  unit .
> VARIABLE LABELS unit 'Unit'.
> EXECUTE .
>
> *Define Variable Properties.
> *unit.
> VARIABLE LEVEL unit  (Nominal).
> FORMATS unit (F8.0).
> VALUE LABELS  unit
>     7  'B10E'
>     1  'B10I'
>     8  'B10S'
>     9  'B11E'
>     3  'B11I'
>   12  'B11S'
>   11  'B5W'
>   10  'B7E'
>     2  'B7I'
>   13  'B7S'
>   14  'B8'
>   15  'B8E'
>   16  'B9E'
>     4  'B9I'
>   17  'B9S'
>   18  'BW2R'
>   19  'C10'
>   20  'C12'
>   21  'C8'
>     5  'C9EI'
>     6  'C9WI'
>   22  'CB4'
>   24  'CB5'
>   23  'CB5R'
>   25  'CB6'
>   26  'JB4'
>   27  'N10'
>   28  'N11'
>   29  'N12'
>   30  'N9'
>   31  'N9S'  .
> EXECUTE.
>
> RECODE
>  unit
>  (1 thru 6=1)  INTO  group .
> EXECUTE .
>
>
> RECODE
>  unit
>  (7 thru 31=2)  INTO  group .
> EXECUTE .
>
> *Define Variable Properties.
> *group.
> VARIABLE LEVEL group  (Nominal).
> VARIABLE LABELS group  'Group'.
> VALUE LABELS  group
>     1  'ICU'
>     2  'Other'  .
> EXECUTE.
>
> RECODE
>  gluc
>  (0 thru 40=1)  (41 thru 65=2)  (66 thru 110=3)  (111 thru 150=4)  (151
> thru
>  180=5)  (181 thru 200=6)  (201 thru 250=7)  (250 thru 300=8)  (301 thru
>  Highest=9)  INTO  gluCat .
> VARIABLE LABELS gluCat 'Glucose Categories'.
> EXECUTE .
> *Define Variable Properties.
> *glucat.
> VARIABLE LEVEL glucat  (Ordinal).
> VALUE LABELS  glucat
>     1  '0-40'
>     2  '41-65'
>     3  '66-110'
>     4  '111-150'
>     5  '151-180'
>     6  '181-200'
>     7  '201-250'
>     8  '250-300'
>     9  '>300'  .
> EXECUTE.
>
> SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose.sav'
>  /COMPRESSED.
>
>
> FILTER OFF.
> USE ALL.
> SELECT IF(group = 1).
> EXECUTE .
>
> SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose_ICU.sav'
>  /COMPRESSED.
>
> SET MPRINT=yes /PRINTBACK=yes.
>
> *MACRO STARTS.
> *///////////////////////////////////////////////////////////////////////////
> /////////////.
> DEFINE !GluChrt (UNITS= !TOKENS(1))
>
> !DO !I = 1 !TO 6.
>
> *6 = # of units reported - adjust as required.
>
>
> USE ALL.
> COMPUTE filter_$=(unit = !I).
> VARIABLE LABEL filter_$ 'unit = 1 (FILTER)'.
> VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
> FORMAT filter_$ (f1.0).
> FILTER BY filter_$.
> EXECUTE .
>
> IGRAPH /VIEWNAME='Bar Chart' /X1 = VAR(glucat) TYPE = CATEGORICAL /Y = $pct
>  /COLOR = VAR(unit) TYPE = CATEGORICAL CLUSTER /COORDINATE = VERTICAL
>  /X1LENGTH=6.0 /YLENGTH=4.0 /X2LENGTH=3.0
>  /CHARTLOOK='C:\Program Files\SPSS\Looks\Chalkboard.clo' /CATORDER VAR
> (glucat)
>  (ASCENDING VALUES OMITEMPTY) /BAR KEY=ON LABEL INSIDE N  SHAPE = RECTANGLE
>  BASELINE = AUTO.
>
>
> FILTER OFF.
> USE ALL.
> EXECUTE .
>
> !DOEND.
> !ENDDEFINE.
> *///////////////////////////////////////////////////////////////////////////
> /////////////.
>
> WRITE OUTFILE = 'C:\TEMP\SYNTAX.SPS'  /'!GluChrt UNIT='UNIT.
> EXECUTE.
>
> INCLUDE 'C:\TEMP\SYNTAX.SPS'.
>
> * Define a macro which will yield the current Date.
> String #CDate(A9).
> COMPUTE #CDate=$Date.
> Do If $casenum=1.
> Write OUTFILE 'c:\temp\temp.sps' /"DEFINE !date()'"#cdate"'!ENDDEFINE.".
> End If.
> Execute.
> * Run the macro.
> INCLUDE 'c:\temp\temp.sps'.
>
> **SAVE OUTFILE='c:\temp\example1_' + !date + '.sav'.
>
> SCRIPT file="G:\Dbases\GlycemicControl\saveOutAs.sbs" /
> ("G:\Dbases\GlycemicControl\Glucose_ICU.spo") .
> *---------------------------------------------------Do same for group = 2---
> ----------------------------------------------------------------------------
> -----.
>
> GET
>  FILE='G:\Dbases\GlycemicControl\Glucose.sav'.
>
>
> FILTER OFF.
> USE ALL.
> SELECT IF(group = 2).
> EXECUTE .
>
> SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose_OtherFloors.sav'
>  /COMPRESSED.
>
> SET MPRINT=yes /PRINTBACK=yes.
>
> *MACRO STARTS.
> *///////////////////////////////////////////////////////////////////////////
> /////////////.
> DEFINE !GluChrt (UNITS= !TOKENS(1))
>
> !DO !I = 7 !TO 31.
>
> USE ALL.
> COMPUTE filter_$=(unit = !I).
> VARIABLE LABEL filter_$ 'unit = 1 (FILTER)'.
> VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
> FORMAT filter_$ (f1.0).
> FILTER BY filter_$.
> EXECUTE .
>
> IGRAPH /VIEWNAME='Bar Chart' /X1 = VAR(glucat) TYPE = CATEGORICAL /Y = $pct
>  /COLOR = VAR(unit) TYPE = CATEGORICAL CLUSTER /COORDINATE = VERTICAL
>  /X1LENGTH=6.0 /YLENGTH=4.0 /X2LENGTH=3.0
>  /CHARTLOOK='C:\Program Files\SPSS\Looks\Chalkboard.clo' /CATORDER VAR
> (glucat)
>  (ASCENDING VALUES OMITEMPTY) /BAR KEY=ON LABEL INSIDE N  SHAPE = RECTANGLE
>  BASELINE = AUTO.
>
>
> FILTER OFF.
> USE ALL.
> EXECUTE .
>
> !DOEND.
> !ENDDEFINE.
> *///////////////////////////////////////////////////////////////////////////
> /////////////.
>
> WRITE OUTFILE = 'C:\TEMP\SYNTAX.SPS'  /'!GluChrt UNIT='UNIT.
> EXECUTE.
>
> INCLUDE 'C:\TEMP\SYNTAX.SPS'.
>
> SCRIPT file="G:\Dbases\GlycemicControl\saveOutAs.sbs" /
> ("G:\Dbases\GlycemicControl\Glucose_OtherFloors.spo") .
>
>
> GET DATA /TYPE=ODBC /CONNECT=
> 'DSN=LAB;UID=lab_user;PWD=''x/q-s6V#U"^#u.o'
>  /SQL =
>  'SELECT  "T12"."visitnum" AS "visitnum",  "T12"."seq4c" AS "seq4c",  '
>  '"T12"."seq5" AS "seq5",  "T12"."obrdate" AS "obrdate",  "T12"."YYYY" AS '
>  '"YYYY",  "T12"."MM" AS "MM",  "T12"."DD" AS "DD",  "T12"."seq12" AS '
>  '"seq12" FROM  "LAB"."dbo"."vw_Glucose" "T12"'
>  .
> VARIABLE LABELS  visitnum "visitnum" seq4c "seq4c" seq5 "seq5" obrdate
>  "obrdate" YYYY "YYYY" MM "MM" DD "DD" seq12 "seq12".
> CACHE.
> EXECUTE.
> COMPUTE Gluc = NUMBER(seq5,f8) .
> EXECUTE .
> AUTORECODE
>  VARIABLES=seq4c  /INTO test
>  /PRINT.
>
>
> COMPUTE unit_1 = INDEX(seq12,'^') .
> EXECUTE .
>
>
> STRING unit_2 (A8).
> COMPUTE unit_2 = SUBSTR(seq12,1,unit_1-1) .
> EXECUTE .
> *AUTORECODE
>  * VARIABLES=unit_2  /INTO unit
>  */PRINT.
>
>
> RECODE
>  unit_2
>  ('B10E'=7)  ('B10I'=1)  ('B10S'=8)  ('B11E'=9)  ('B7I'=2)  ('B7E'=10)
>  ('B5W'=11)  ('B11S'=12)  ('B11I'=3)  ('B7S'=13)  ('B8'=14)  ('B8E'=15)
>  ('B9E'=16)  ('B9I'=4)  ('B9S'=17)  ('BW2R'=18)  ('C10'=19)  ('C12'=20)
>  ('C8'=21)  ('C9EI'=5)  ('C9WI'=6)  ('CB4'=22)  ('CB5R'=23)  ('CB5'=24)
>  ('CB6'=25)  ('JB4'=26)  ('N10'=27)  ('N11'=28)  ('N12'=29)  ('N9'=30)
>  ('N9S'=31)  INTO  unit .
> VARIABLE LABELS unit 'Unit'.
> EXECUTE .
>
> *Define Variable Properties.
> *unit.
> VARIABLE LEVEL unit  (Nominal).
> FORMATS unit (F8.0).
> VALUE LABELS  unit
>     7  'B10E'
>     1  'B10I'
>     8  'B10S'
>     9  'B11E'
>     3  'B11I'
>   12  'B11S'
>   11  'B5W'
>   10  'B7E'
>     2  'B7I'
>   13  'B7S'
>   14  'B8'
>   15  'B8E'
>   16  'B9E'
>     4  'B9I'
>   17  'B9S'
>   18  'BW2R'
>   19  'C10'
>   20  'C12'
>   21  'C8'
>     5  'C9EI'
>     6  'C9WI'
>   22  'CB4'
>   24  'CB5'
>   23  'CB5R'
>   25  'CB6'
>   26  'JB4'
>   27  'N10'
>   28  'N11'
>   29  'N12'
>   30  'N9'
>   31  'N9S'  .
> EXECUTE.
>
> RECODE
>  unit
>  (1 thru 6=1)  INTO  group .
> EXECUTE .
>
>
> RECODE
>  unit
>  (7 thru 31=2)  INTO  group .
> EXECUTE .
>
> *Define Variable Properties.
> *group.
> VARIABLE LEVEL group  (Nominal).
> VARIABLE LABELS group  'Group'.
> VALUE LABELS  group
>     1  'ICU'
>     2  'Other'  .
> EXECUTE.
>
> RECODE
>  gluc
>  (0 thru 40=1)  (41 thru 65=2)  (66 thru 110=3)  (111 thru 150=4)  (151
> thru
>  180=5)  (181 thru 200=6)  (201 thru 250=7)  (250 thru 300=8)  (301 thru
>  Highest=9)  INTO  gluCat .
> VARIABLE LABELS gluCat 'Glucose Categories'.
> EXECUTE .
> *Define Variable Properties.
> *glucat.
> VARIABLE LEVEL glucat  (Ordinal).
> VALUE LABELS  glucat
>     1  '0-40'
>     2  '41-65'
>     3  '66-110'
>     4  '111-150'
>     5  '151-180'
>     6  '181-200'
>     7  '201-250'
>     8  '250-300'
>     9  '>300'  .
> EXECUTE.
>
> SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose.sav'
>  /COMPRESSED.
>
>
> FILTER OFF.
> USE ALL.
> SELECT IF(group = 1).
> EXECUTE .
>
> SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose_ICU.sav'
>  /COMPRESSED.
>
> SET MPRINT=yes /PRINTBACK=yes.
>
> *MACRO STARTS.
> *///////////////////////////////////////////////////////////////////////////
> /////////////.
> DEFINE !GluChrt (UNITS= !TOKENS(1))
>
> !DO !I = 1 !TO 6.
>
> *6 = # of units reported - adjust as required.
>
>
> USE ALL.
> COMPUTE filter_$=(unit = !I).
> VARIABLE LABEL filter_$ 'unit = 1 (FILTER)'.
> VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
> FORMAT filter_$ (f1.0).
> FILTER BY filter_$.
> EXECUTE .
>
> IGRAPH /VIEWNAME='Bar Chart' /X1 = VAR(glucat) TYPE = CATEGORICAL /Y = $pct
>  /COLOR = VAR(unit) TYPE = CATEGORICAL CLUSTER /COORDINATE = VERTICAL
>  /X1LENGTH=6.0 /YLENGTH=4.0 /X2LENGTH=3.0
>  /CHARTLOOK='C:\Program Files\SPSS\Looks\Chalkboard.clo' /CATORDER VAR
> (glucat)
>  (ASCENDING VALUES OMITEMPTY) /BAR KEY=ON LABEL INSIDE N  SHAPE = RECTANGLE
>  BASELINE = AUTO.
>
>
> FILTER OFF.
> USE ALL.
> EXECUTE .
>
> !DOEND.
> !ENDDEFINE.
> *///////////////////////////////////////////////////////////////////////////
> /////////////.
>
> WRITE OUTFILE = 'C:\TEMP\SYNTAX.SPS'  /'!GluChrt UNIT='UNIT.
> EXECUTE.
>
> INCLUDE 'C:\TEMP\SYNTAX.SPS'.
>
> * Define a macro which will yield the current Date.
> String #CDate(A9).
> COMPUTE #CDate=$Date.
> Do If $casenum=1.
> Write OUTFILE 'c:\temp\temp.sps' /"DEFINE !date()'"#cdate"'!ENDDEFINE.".
> End If.
> Execute.
> * Run the macro.
> INCLUDE 'c:\temp\temp.sps'.
>
> **SAVE OUTFILE='c:\temp\example1_' + !date + '.sav'.
>
> SCRIPT file="G:\Dbases\GlycemicControl\saveOutAs.sbs" /
> ("G:\Dbases\GlycemicControl\Glucose_ICU.spo") .
> *---------------------------------------------------Do same for group = 2---
> ----------------------------------------------------------------------------
> -----.
>
> GET
>  FILE='G:\Dbases\GlycemicControl\Glucose.sav'.
>
>
> FILTER OFF.
> USE ALL.
> SELECT IF(group = 2).
> EXECUTE .
>
> SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose_OtherFloors.sav'
>  /COMPRESSED.
>
> SET MPRINT=yes /PRINTBACK=yes.
>
> *MACRO STARTS.
> *///////////////////////////////////////////////////////////////////////////
> /////////////.
> DEFINE !GluChrt (UNITS= !TOKENS(1))
>
> !DO !I = 7 !TO 31.
>
> USE ALL.
> COMPUTE filter_$=(unit = !I).
> VARIABLE LABEL filter_$ 'unit = 1 (FILTER)'.
> VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
> FORMAT filter_$ (f1.0).
> FILTER BY filter_$.
> EXECUTE .
>
> IGRAPH /VIEWNAME='Bar Chart' /X1 = VAR(glucat) TYPE = CATEGORICAL /Y = $pct
>  /COLOR = VAR(unit) TYPE = CATEGORICAL CLUSTER /COORDINATE = VERTICAL
>  /X1LENGTH=6.0 /YLENGTH=4.0 /X2LENGTH=3.0
>  /CHARTLOOK='C:\Program Files\SPSS\Looks\Chalkboard.clo' /CATORDER VAR
> (glucat)
>  (ASCENDING VALUES OMITEMPTY) /BAR KEY=ON LABEL INSIDE N  SHAPE = RECTANGLE
>  BASELINE = AUTO.
>
>
> FILTER OFF.
> USE ALL.
> EXECUTE .
>
> !DOEND.
> !ENDDEFINE.
> *///////////////////////////////////////////////////////////////////////////
> /////////////.
>
> WRITE OUTFILE = 'C:\TEMP\SYNTAX.SPS'  /'!GluChrt UNIT='UNIT.
> EXECUTE.
>
> INCLUDE 'C:\TEMP\SYNTAX.SPS'.
>
> SCRIPT file="G:\Dbases\GlycemicControl\saveOutAs.sbs" /
> ("G:\Dbases\GlycemicControl\Glucose_OtherFloors.spo") .
>
>
> GET DATA /TYPE=ODBC /CONNECT=
> 'DSN=LAB;UID=lab_user;PWD=''x/q-s6V#U"^#u.o'
>  /SQL =
>  'SELECT  "T12"."visitnum" AS "visitnum",  "T12"."seq4c" AS "seq4c",  '
>  '"T12"."seq5" AS "seq5",  "T12"."obrdate" AS "obrdate",  "T12"."YYYY" AS '
>  '"YYYY",  "T12"."MM" AS "MM",  "T12"."DD" AS "DD",  "T12"."seq12" AS '
>  '"seq12" FROM  "LAB"."dbo"."vw_Glucose" "T12"'
>  .
> VARIABLE LABELS  visitnum "visitnum" seq4c "seq4c" seq5 "seq5" obrdate
>  "obrdate" YYYY "YYYY" MM "MM" DD "DD" seq12 "seq12".
> CACHE.
> EXECUTE.
> COMPUTE Gluc = NUMBER(seq5,f8) .
> EXECUTE .
> AUTORECODE
>  VARIABLES=seq4c  /INTO test
>  /PRINT.
>
>
> COMPUTE unit_1 = INDEX(seq12,'^') .
> EXECUTE .
>
>
> STRING unit_2 (A8).
> COMPUTE unit_2 = SUBSTR(seq12,1,unit_1-1) .
> EXECUTE .
> *AUTORECODE
>  * VARIABLES=unit_2  /INTO unit
>  */PRINT.
>
>
> RECODE
>  unit_2
>  ('B10E'=7)  ('B10I'=1)  ('B10S'=8)  ('B11E'=9)  ('B7I'=2)  ('B7E'=10)
>  ('B5W'=11)  ('B11S'=12)  ('B11I'=3)  ('B7S'=13)  ('B8'=14)  ('B8E'=15)
>  ('B9E'=16)  ('B9I'=4)  ('B9S'=17)  ('BW2R'=18)  ('C10'=19)  ('C12'=20)
>  ('C8'=21)  ('C9EI'=5)  ('C9WI'=6)  ('CB4'=22)  ('CB5R'=23)  ('CB5'=24)
>  ('CB6'=25)  ('JB4'=26)  ('N10'=27)  ('N11'=28)  ('N12'=29)  ('N9'=30)
>  ('N9S'=31)  INTO  unit .
> VARIABLE LABELS unit 'Unit'.
> EXECUTE .
>
> *Define Variable Properties.
> *unit.
> VARIABLE LEVEL unit  (Nominal).
> FORMATS unit (F8.0).
> VALUE LABELS  unit
>     7  'B10E'
>     1  'B10I'
>     8  'B10S'
>     9  'B11E'
>     3  'B11I'
>   12  'B11S'
>   11  'B5W'
>   10  'B7E'
>     2  'B7I'
>   13  'B7S'
>   14  'B8'
>   15  'B8E'
>   16  'B9E'
>     4  'B9I'
>   17  'B9S'
>   18  'BW2R'
>   19  'C10'
>   20  'C12'
>   21  'C8'
>     5  'C9EI'
>     6  'C9WI'
>   22  'CB4'
>   24  'CB5'
>   23  'CB5R'
>   25  'CB6'
>   26  'JB4'
>   27  'N10'
>   28  'N11'
>   29  'N12'
>   30  'N9'
>   31  'N9S'  .
> EXECUTE.
>
> RECODE
>  unit
>  (1 thru 6=1)  INTO  group .
> EXECUTE .
>
>
> RECODE
>  unit
>  (7 thru 31=2)  INTO  group .
> EXECUTE .
>
> *Define Variable Properties.
> *group.
> VARIABLE LEVEL group  (Nominal).
> VARIABLE LABELS group  'Group'.
> VALUE LABELS  group
>     1  'ICU'
>     2  'Other'  .
> EXECUTE.
>
> RECODE
>  gluc
>  (0 thru 40=1)  (41 thru 65=2)  (66 thru 110=3)  (111 thru 150=4)  (151
> thru
>  180=5)  (181 thru 200=6)  (201 thru 250=7)  (250 thru 300=8)  (301 thru
>  Highest=9)  INTO  gluCat .
> VARIABLE LABELS gluCat 'Glucose Categories'.
> EXECUTE .
> *Define Variable Properties.
> *glucat.
> VARIABLE LEVEL glucat  (Ordinal).
> VALUE LABELS  glucat
>     1  '0-40'
>     2  '41-65'
>     3  '66-110'
>     4  '111-150'
>     5  '151-180'
>     6  '181-200'
>     7  '201-250'
>     8  '250-300'
>     9  '>300'  .
> EXECUTE.
>
> SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose.sav'
>  /COMPRESSED.
>
>
> FILTER OFF.
> USE ALL.
> SELECT IF(group = 1).
> EXECUTE .
>
> SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose_ICU.sav'
>  /COMPRESSED.
>
> SET MPRINT=yes /PRINTBACK=yes.
>
> *MACRO STARTS.
> *///////////////////////////////////////////////////////////////////////////
> /////////////.
> DEFINE !GluChrt (UNITS= !TOKENS(1))
>
> !DO !I = 1 !TO 6.
>
> *6 = # of units reported - adjust as required.
>
>
> USE ALL.
> COMPUTE filter_$=(unit = !I).
> VARIABLE LABEL filter_$ 'unit = 1 (FILTER)'.
> VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
> FORMAT filter_$ (f1.0).
> FILTER BY filter_$.
> EXECUTE .
>
> IGRAPH /VIEWNAME='Bar Chart' /X1 = VAR(glucat) TYPE = CATEGORICAL /Y = $pct
>  /COLOR = VAR(unit) TYPE = CATEGORICAL CLUSTER /COORDINATE = VERTICAL
>  /X1LENGTH=6.0 /YLENGTH=4.0 /X2LENGTH=3.0
>  /CHARTLOOK='C:\Program Files\SPSS\Looks\Chalkboard.clo' /CATORDER VAR
> (glucat)
>  (ASCENDING VALUES OMITEMPTY) /BAR KEY=ON LABEL INSIDE N  SHAPE = RECTANGLE
>  BASELINE = AUTO.
>
>
> FILTER OFF.
> USE ALL.
> EXECUTE .
>
> !DOEND.
> !ENDDEFINE.
> *///////////////////////////////////////////////////////////////////////////
> /////////////.
>
> WRITE OUTFILE = 'C:\TEMP\SYNTAX.SPS'  /'!GluChrt UNIT='UNIT.
> EXECUTE.
>
> INCLUDE 'C:\TEMP\SYNTAX.SPS'.
>
> * Define a macro which will yield the current Date.
> String #CDate(A9).
> COMPUTE #CDate=$Date.
> Do If $casenum=1.
> Write OUTFILE 'c:\temp\temp.sps' /"DEFINE !date()'"#cdate"'!ENDDEFINE.".
> End If.
> Execute.
> * Run the macro.
> INCLUDE 'c:\temp\temp.sps'.
>
> **SAVE OUTFILE='c:\temp\example1_' + !date + '.sav'.
>
> SCRIPT file="G:\Dbases\GlycemicControl\saveOutAs.sbs" /
> ("G:\Dbases\GlycemicControl\Glucose_ICU.spo") .
> *---------------------------------------------------Do same for group = 2---
> ----------------------------------------------------------------------------
> -----.
>
> GET
>  FILE='G:\Dbases\GlycemicControl\Glucose.sav'.
>
>
> FILTER OFF.
> USE ALL.
> SELECT IF(group = 2).
> EXECUTE .
>
> SAVE OUTFILE='G:\Dbases\GlycemicControl\Glucose_OtherFloors.sav'
>  /COMPRESSED.
>
> SET MPRINT=yes /PRINTBACK=yes.
>
> *MACRO STARTS.
> *///////////////////////////////////////////////////////////////////////////
> /////////////.
> DEFINE !GluChrt (UNITS= !TOKENS(1))
>
> !DO !I = 7 !TO 31.
>
> USE ALL.
> COMPUTE filter_$=(unit = !I).
> VARIABLE LABEL filter_$ 'unit = 1 (FILTER)'.
> VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
> FORMAT filter_$ (f1.0).
> FILTER BY filter_$.
> EXECUTE .
>
> IGRAPH /VIEWNAME='Bar Chart' /X1 = VAR(glucat) TYPE = CATEGORICAL /Y = $pct
>  /COLOR = VAR(unit) TYPE = CATEGORICAL CLUSTER /COORDINATE = VERTICAL
>  /X1LENGTH=6.0 /YLENGTH=4.0 /X2LENGTH=3.0
>  /CHARTLOOK='C:\Program Files\SPSS\Looks\Chalkboard.clo' /CATORDER VAR
> (glucat)
>  (ASCENDING VALUES OMITEMPTY) /BAR KEY=ON LABEL INSIDE N  SHAPE = RECTANGLE
>  BASELINE = AUTO.
>
>
> FILTER OFF.
> USE ALL.
> EXECUTE .
>
> !DOEND.
> !ENDDEFINE.
> *///////////////////////////////////////////////////////////////////////////
> /////////////.
>
> WRITE OUTFILE = 'C:\TEMP\SYNTAX.SPS'  /'!GluChrt UNIT='UNIT.
> EXECUTE.
>
> INCLUDE 'C:\TEMP\SYNTAX.SPS'.
>
> SCRIPT file="G:\Dbases\GlycemicControl\saveOutAs.sbs" /
> ("G:\Dbases\GlycemicControl\Glucose_OtherFloors.spo") .
>