Compare (superimpose) two histograms
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | * How can I compare (superimpose) 2 histogram. ******************************. * First method. ******************************. * Answer posted to newsgroup by Raynald Levesque on 2003/02/13. GET FILE='c:\\program files\\spss\\employee data.sav'. COMPUTE beg=TRUNC(salbegin/5000). COMPUTE sal=TRUNC(salary/5000). SORT CASES BY beg. AGGREGATE OUTFILE='c:\\temp\\beg.sav' /PRESORTED /BREAK=beg /nbeg=n. SORT CASES BY sal. AGGREGATE OUTFILE=* /PRESORTED /BREAK=sal /nsal=n. MATCH FILES FILE=* /RENAME=(sal=beg) /FILE='c:\\temp\\beg.sav' /BY=beg. GRAPH /LINE(MULTIPLE)= VALUE( nbeg nsal ) BY beg . ******************************. * Second Method. ******************************. Date: Fri, 23 Jun 2000 20:38:37 -0400 Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU> From: Raynald Levesque <rlevesque@VIDEOTRON.CA> Subject: Re: superimpsed histograms Hi Arthur! This is a possible solution: *Define dummy data file for illustration purposes. NEW file. SET SEED=975316421. INPUT PROGRAM. - LOOP id=1 TO 50. - COMPUTE income=RV.NORMAL(35,5). - COMPUTE group=UNIFORM(1)>.5. - END CASE. - END LOOP. - END FILE. END INPUT PROGRAM. EXECUTE. SAVE OUTFILE='temp.sav'. GRAPH /HISTOGRAM=income . * look at the histogram and note the smallest value and the range of each bin. * in this case the smallest mid point of a bin is 18,000 and the range is 2000. * Recode the income values as follows. LOOP cnt=18 TO 46 BY 2. - IF RANGE(income,cnt-1,cnt+0.99999) income1=cnt. END LOOP. EXECUTE. GRAPH /BAR(GROUPED)=COUNT BY income1 BY group /MISSING=REPORT. |
Related pages
...