Date: Thu, 3 Oct 2002 19:42:01 +0100 Reply-To: David Lindsay Sender: "SPSSX(r) Discussion" From: David Lindsay Subject: Macro Problem (raynauld?) Content-type: text/plain; charset=US-ASCII Hi Listers, I am trying to generalise some syntax that produces a stacked bar chart from a rating scale, q35, by demographic variables (totcol, dqd, sex).. The syntax is below: vector v(18). compute dummy = 1. AGGREGATE OUTFILE='c:\temp\out1.sav' /PRESORTED /BREAK=dummy /vmax1 = max (totrow). *. MATCH FILES FILE=* /TABLE='c:\temp\out1.sav' /BY dummy /DROP dummy. EXECUTE. compute dummy = 1. AGGREGATE OUTFILE='c:\temp\out1.sav' /PRESORTED /BREAK=dummy /vmax2 = max (dqd). *. MATCH FILES FILE=* /TABLE='c:\temp\out1.sav' /BY dummy /DROP dummy. EXECUTE. compute dummy = 1. AGGREGATE OUTFILE='c:\temp\out1.sav' /PRESORTED /BREAK=dummy /vmax3 = max (sex). *. MATCH FILES FILE=* /TABLE='c:\temp\out1.sav' /BY dummy /DROP dummy. EXECUTE. vector v = v1 to v18. loop #i = 1 to vmax1. if ( totcol = #i ) v(#i) = q35. end loop. exe. vector v = v1 to v18. loop i = (vmax1 + 1) to (vmax1 + vmax2). if ( dqd = (i - vmax1 ) ) v(i) = q35. end loop. exe. vector v = v1 to v18. loop i = (vmax1 + vmax2 + 1) to (vmax1 + vmax2 + vmax3). if ( sex = (i - vmax1 - vmax2) ) v(i) = q35. end loop. exe. VECTOR var=v1 TO v8. LOOP var=1 TO 8. COMPUTE val1=var(var). XSAVE OUTFILE='c:\temp\temp.sav' /KEEP=id var val1. END LOOP. EXECUTE. GET FILE='c:\temp\temp.sav'. VALUE LABEL var 1 'Total' 2 'user1' 3 'user2' 4 'user3' 5 'user4' 6 'user5' 7 'male' 8 'female' . GRAPH /BAR(STACK)=count BY var BY val1 /TEMPLATE='f:\DATA\SPSS\ski\Yogurt2\bar100%N.sct' /MISSING=REPORT. My efforts at generalisng the syntax for any number of variables have fallen at the first hurdle!! The list of the demographic variables that I want to input each time is in !list1 DEFINE !list1() totcol dqd sex !ENDDEFINE. vector v(18). vector vvmax(18). set mprint on. DEFINE !newvar (). COMPUTE dummy=1. *. !LET !f=max. !LET !dropl='dummy'. *. vector v = v1 to v18. vector vvmax = vvmax1 to vvmax18. !do !i !in (!list1). !LET !vvm = !CONCAT(vvmax, !i). AGGREGATE OUTFILE='c:\temp\out1.sav' /PRESORTED /BREAK=dummy / !vvm = !f(!i). *. MATCH FILES FILE=* /TABLE='c:\temp\out1.sav' /BY dummy /DROP !dropl. EXECUTE. !doend. !ENDDEFINE. *execute the prog. !newvar. Any pointers would be very welcome, how I correct this bit and then generalise the next section. Thanks, Thanks-- David Lindsay Significantly Different! Research, Reading,Berks. GB Market Research Services & Consultancy http://www.SDResearch.com/ 

Back to: Top of message | Previous page | Main SPSSX-L page