1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
* This syntax is an example of how to use the macro file "dograph.sps".
* I assume that the syntax "dograph.sps" and the "dograph.sct" jhave been saved in c:\\temp.
* rlevesque@videotron.ca.


SET MPRINT=yes.
* Define dummy data file for illustration purposes.
NEW file.
INPUT PROGRAM.
SET SEED=986431.
LOOP id=1 TO 500.
COMPUTE region=RND(UNIFORM(5)+.5).
COMPUTE job_cat=RND(UNIFORM(5)+.5).

* The purpose of the next 3 lines is to get different number of cases and
* different range of values within each categories.
DO IF UNIFORM(1)<region/5.
COMPUTE value1=RND(region*10+UNIFORM(60)).
COMPUTE value9=RND(job_cat*25+UNIFORM(60+region*2)).
END CASE.
+END IF.
END LOOP.
END FILE.
END INPUT PROGRAM.
EXECUTE.
SAVE OUTFILE='c:\\temp\\data0.sav'.

********************.
* Using the macro.
********************.

*Balance of syntax does two complete sample jobs.
SET MPRINT=yes.
INCLUDE FILE="c:\\temp\\dograph.sps".

* Do the graphs for value1 by region (say want 20 bins).
GET FILE='C:\\temp\\data0.sav'.
!dograph cat=region val=value1 nbbins=20 title="Histograms by Regions".

* Do the graphs for value9 by job_cat (say want 10 bins).
GET FILE='C:\\temp\\data0.sav'.
!dograph cat=job_cat val=value9 nbbins=10 title="Histograms by Job Categories".