LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2000)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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_AMTSLS_AMT Sum Sum DEP_KEY2.00712 739 1.00550 631 3.00524 536 4.00888 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


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