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
Content-Type: text/plain; charset="iso-8859-1"
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.
From: Raynald Levesque [mailto:firstname.lastname@example.org]
Sent: Friday, October 11, 2002 6:14 PM
Subject: Re: Looking for help with syntax-data manipulation
This is one approach:
DATA LIST LIST /diseases(A16) meats dairy eggs medicine drug perfume oil
'bone cancer' 1 1 . 1 . 1 .
'Brain cancer' 1 . 1 . 1 . 1
'Lung cancer' . 1 . . . . 1
SAVE OUTFILE='c:\temp\original data.sav'.
FLIP VARIABLES=meats dairy eggs medicine drug perfume oil.
STRING food1 TO food7(A8).
VECTOR food=food1 TO food7.
/food1 TO food7=MAX(food1 TO food7).
MATCH FILES TABLE=*
VECTOR foodc=meats TO oil /food=food1 TO food7.
LOOP cnt=1 TO 7.
IF foodc(cnt)=1 foodlist=CONCAT(RTRIM(foodlist),' ',food(cnt)).
/FORMAT=VALIDLIST NOCASENUM TOTAL
/TITLE='List of food associated with diseases'
This is the output:
List of food associated with diseases
1 bone cancer MEATS DAIRY MEDICINE PERFUME
2 Brain cancer MEATS EGGS DRUG OIL
3 Lung cancer DAIRY OIL
Raynald Levesque email@example.com
Visit my SPSS Pages http://pages.infinit.net/rlevesqu/index.htm
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On Behalf Of
Sent: October 11, 2002 4:50 PM
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 .
Lung cancer . 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
Have a nice weekend.