| Date: | Mon, 26 Jun 2000 19:54:41 -0400 |
| Reply-To: | Raynald Levesque <rlevesque@VIDEOTRON.CA> |
| Sender: | "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU> |
| From: | Raynald Levesque <rlevesque@VIDEOTRON.CA> |
| Subject: | Re: complicated table |
| Content-type: | text/plain; charset=iso-8859-1 |
Hi Paul,
I believe the following syntax does what you want.
SET SEED=87654321.
INPUT PROGRAM.
LOOP #I = 1 TO 200.
COMPUTE month= TRUNC(UNIFORM(1)*2)+1.
COMPUTE year= TRUNC(UNIFORM(1)*3)+1.
COMPUTE odse_key= TRUNC(UNIFORM(1)*4)+1.
COMPUTE sls_amt= TRUNC(UNIFORM(1)*50)+1.
COMPUTE profit= TRUNC(UNIFORM(1)*30)+1.
COMPUTE seg_key=TRUNC(UNIFORM(1)*4)+1.
COMPUTE dep_key=TRUNC(UNIFORM(1)*4)+1.
COMPUTE quart=TRUNC(UNIFORM(1)*16)+1.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
EXECUTE.
if sls_amt=0 sls_amt=0.01.
COMPUTE pmargin =(profit/sls_amt)*100 .
EXECUTE .
format pmargin (comma).
exe.
WEIGHT BY sls_amt.
SORT CASES BY
pmargin (A) .
*****************************************************.
* Section (A)Below syntax generate sales by month by brand.
*****************************************************.
* Paul, I commented the next line as it does not look right.
*WEIGHT OFF.
AGGREGATE
/OUTFILE=*
/BREAK=month dep_key
/sls_amt= SUM(sls_amt).
*Create a column for each of month1 and month2.
VECTOR month1(2F8.0).
COMPUTE month1(month)=sls_amt.
AGGREGATE
/OUTFILE=*
/BREAK=dep_key
/sls_amt1 TO sls_amt2=SUM(month11 TO month12).
* Calculate percentage change.
COMPUTE pc=0.
IF sls_amt1>0 pc=(sls_amt2-sls_amt1)/sls_amt1.
* Send results to output window.
SUMMARIZE
/TABLES=dep_key sls_amt1 sls_amt2 pc
/FORMAT=VALIDLIST NOCASENUM TOTAL
/TITLE='% of sales increase month2/month1'
/MISSING=VARIABLE
/CELLS=NONE .
(For your info: It would also be possible to show the a line at the bottom
of the output which would contain the overall percentage increase for all
brands combined)
HTH
Raynald Levesque rlevesque@videotron.ca
----- Original Message -----
From: Paul Yeo
Newsgroups: bit.listserv.spssx-l
To: SPSSX-L@LISTSERV.UGA.EDU
Sent: Monday, June 26, 2000 9:47 AM
Subject: complicated table
I have a question on table , Hope that some one will help my to modify
section (A) syntex to generate % change in month 1 and month 2.
*****************************************************.
* This section creates the sample data file.
*****************************************************.
SET SEED=87654321.
INPUT PROGRAM.
LOOP #I = 1 TO 200.
COMPUTE month= TRUNC(UNIFORM(1)*2)+1.
COMPUTE year= TRUNC(UNIFORM(1)*3)+1.
COMPUTE odse_key= TRUNC(UNIFORM(1)*4)+1.
COMPUTE sls_amt= TRUNC(UNIFORM(1)*50)+1.
COMPUTE profit= TRUNC(UNIFORM(1)*30)+1.
COMPUTE seg_key=TRUNC(UNIFORM(1)*4)+1.
COMPUTE dep_key=TRUNC(UNIFORM(1)*4)+1.
COMPUTE quart=TRUNC(UNIFORM(1)*16)+1.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
EXECUTE.
if sls_amt=0 sls_amt=0.01.
COMPUTE pmargin =(profit/sls_amt)*100 .
EXECUTE .
format pmargin (comma).
exe.
WEIGHT BY sls_amt.
SORT CASES BY
pmargin (A) .
*****************************************************.
* Section (A)Below syntax generate sales by month by brand.
*****************************************************.
WEIGHT off.
format sls_amt(comma).
TABLES
/FORMAT BLANK MISSING('.')
/OBSERVATION= sls_amt
/GBASE=CASES
/TABLE=dep_key BY month > sls_amt
/sort=dep_key
/STATISTICS
sum(sls_amt ).
*****************************************************.
* Above syntex have generated following table.
*****************************************************.
Tables
öòòòòòòòòòòòòûòòòòòòòòòòòòòòòø
ó óMONTH ó
ó ùòòòòòòòûòòòòòòòú
ó ó1.00 ó2.00 ó
ó ùòòòòòòòôòòòòòòòú
ó óSLS_AMTóSLS_AMTó
ó ùòòòòòòòôòòòòòòòú
ó óSum óSum ó
ùòòòòòòòûòòòòôòòòòòòòôòòòòòòòú
óDEP_KEYó2.00ó712 ó739 ó
ó ùòòòòôòòòòòòòôòòòòòòòú
ó ó1.00ó550 ó631 ó
ó ùòòòòôòòòòòòòôòòòòòòòú
ó ó3.00ó524 ó536 ó
ó ùòòòòôòòòòòòòôòòòòòòòú
ó ó4.00ó888 ó332 ó
õòòòòòòòüòòòòüòòòòòòòüòòòòòòò÷
¢
*****************************************************.
* My question is how to modify the section (a) syntax , so that it will
compute the % changes of Month 1 compare with Month 2.
*****************************************************.
The formular is = ( month 2 - month 1) / month 1
Paul Yeo
TDS Technology (S) P/L
www.tdstech.com
Tel (65) 3661661
Fax(65) 3621661
|