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 (October 2002)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 15 Oct 2002 16:11:32 -0700
Reply-To:     "Gao, Peter" <PGao@hca.co.orange.ca.us>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         "Gao, Peter" <PGao@hca.co.orange.ca.us>
Subject:      Thank you note
Comments: To: Raynald Levesque <rlevesque@videotron.ca>
Content-Type: text/plain; charset="iso-8859-1"

Dear Raynald,

Thank you for taking the time offering the syntax solution for my task. It worked beautifully. Now I am looking for improvement-- to let the variable labels show up instead of the variable names.

You are great and many thanks.

Peter Gao

-----Original Message----- From: Raynald Levesque [mailto:rlevesque@videotron.ca] Sent: Friday, October 11, 2002 6:14 PM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Re: Looking for help with syntax-data manipulation

Hi

This is one approach:

DATA LIST LIST /diseases(A16) meats dairy eggs medicine drug perfume oil (7F1). BEGIN DATA 'bone cancer' 1 1 . 1 . 1 . 'Brain cancer' 1 . 1 . 1 . 1 'Lung cancer' . 1 . . . . 1 END DATA. LIST.

COMPUTE nobreak=1. SAVE OUTFILE='c:\temp\original data.sav'.

FLIP VARIABLES=meats dairy eggs medicine drug perfume oil. COMPUTE nobreak=1. COMPUTE idx=$CASENUM. STRING food1 TO food7(A8). VECTOR food=food1 TO food7.

COMPUTE food(idx)=case_lbl. AGGREGATE OUTFILE=* /PRESORTED /BREAK=nobreak /food1 TO food7=MAX(food1 TO food7). MATCH FILES TABLE=* /FILE='c:\temp\original data.sav' /BY=nobreak.

STRING foodlist(A255). VECTOR foodc=meats TO oil /food=food1 TO food7. LOOP cnt=1 TO 7. IF foodc(cnt)=1 foodlist=CONCAT(RTRIM(foodlist),' ',food(cnt)). END LOOP.

SUMMARIZE /TABLES=diseases foodlist /FORMAT=VALIDLIST NOCASENUM TOTAL /TITLE='List of food associated with diseases' /MISSING=VARIABLE /CELLS=NONE .

******************. This is the output:

List of food associated with diseases

DISEASES FOODLIST 1 bone cancer MEATS DAIRY MEDICINE PERFUME 2 Brain cancer MEATS EGGS DRUG OIL 3 Lung cancer DAIRY OIL

HTH

Raynald Levesque rlevesque@videotron.ca Visit my SPSS Pages http://pages.infinit.net/rlevesqu/index.htm

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On Behalf Of Gao, Peter Sent: October 11, 2002 4:50 PM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Looking for help with syntax-data manipulation

Dear list members,

I hope someone can help me with this:

I have a matrix of variables, the record line (case) is about disease names, the variables (columns) are names of foods or medicines. Not all entries have a value (have missing values here and there). I am trying to produce an output that will show one food associated with how many diseases or one disease associated with how many foods.

Example of my data (actual data file is large with 53 columns):

diseases meats dairy eggs medicine drug perfume oil bone cancer 1 1 . 1 . 1 . Brain cancer 1 . 1 . 1 . 1 Lung cancer . 1 . . . . 1

output or data will be something like:

bone cancer: meats, dairy medicine perfume Brain cancer: meats, eggs, drug, oil Lung cancer: dairy, oil

The resulting list has varied number of variables.

I wish someone with the expertise can write the syntax to do it. Many thanks in advance.

Have a nice weekend.

Peter Gao


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