spssforum.com from users, for users

SPSSforum.com is the largest free SPSS help resource worldwide.
On this SPSS forum you are sure to get an answer to your question!
Join the forum and let other SPSS users help you.

Join the SPSS users Group on LinkedIn
Join the SPSS Users Group
on LinkedIn
 
SPSSforum.com is a forum for SPSS users. Ask any question you like about SPSS or statistics.

It is currently Fri Sep 03, 2010 3:39 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Iterative analysis
PostPosted: Mon Jan 19, 2009 12:14 pm 
I am analysing hospital admission data to find alcohol-related cases and assign a fraction, indicating the proportion of cases that are alcohol-caused.

The analysis involves creating a variable called alc indicating that the admission is alcohol-related. This is based on the diagnostic code and there are 45 values of alc. Then a fraction (a new variable called af) is applied, based on the value of alc, and the age group and sex of the patient.

I have done similar analysis in the past, but only on the principal diagnosis. This time I need to include the 13 secondary diagnoses and use only the highest fraction.

Can anyone tell me how I can do the following in SPSS:

for each diagnosis (variables diag1 to diag14), assign the alc values (there will need to be 14 alc variables, one for each diagnosis).
For each alc variable assign a fraction (af1 to af14) based on the value of alc, and the age group and sex of the patient.
Check which of the af variables has the highest value and put this value into another variable (maxaf).

I hope this is clear, if not I can post the program I've written to get it working for one diagnosis if that helps.

I'm on a tight time frame with this analysis so any help people can give me to save time wasted in trial and error will be much appreciated.

Thanks in anticipation!


Top
  
 



 Post subject:
PostPosted: Mon Jan 19, 2009 4:25 pm 
Offline
Moderator

Joined: Sun Dec 28, 2008 5:55 pm
Posts: 555
Location: Belo Horizonte, Brasil
The alc values and fractions are related to the other variables using some math formula (like af1+age-10*sex), right?
You can compute new variables for both:
Code:
COMPUTE af1=<FORMULA INCLUDING diag1>
COMPUTE af2=<FORMULA INCLUDING diag2>
......
EXECUTE.

COMPUTE fraction1=<FORMULA INCLUDING af1, age AND sex>
COMPUTE fraction2=<FORMULA INCLUDING af2, age AND sex>
......
EXECUTE.


For the maxaf variable, use COMPUTE again, but with tha MAX function:
Code:
COMPUTE maxaf=MAX(af1 TO af14).
EXECUTE.



It would be good if you could post your commands for this, maybe you're thinking in a faster way and maybe someone can point any common mistakes.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 20, 2009 10:47 am 
Offline

Joined: Tue Jan 20, 2009 10:28 am
Posts: 4
Dear Fierce,

Thanks for your reply! The compute max command is just what I was looking for.

However, the fractions are not calculated using a maths formula, they have been assigned by meta-analysis of the scientific literature. I'll give you an example of the coding I've done so you can see what I mean.

There are two programs, the first creates the alc variable based on the diagnostic code. There are 45 conditions that are alcohol-related so I'll just include a few.

IF (diag1 >= 'C15 ' and diag1 <= 'C159') alc1= 15.
IF (diag1 >= 'C18 ' and diag1 <= 'C189') alc1= 16.
IF (diag1 >= 'C20 ' and diag1 <= 'C209') alc1= 17.

The next program assigns the fraction, according to the value of alc, agegroup and sex. The example below is for males only.

DO IF (alc1 = 15 & sex = 1) .
RECODE
agegp
(2=0.32) (3=0.31) (4=0.30) (5=0.34) (6=0.32) (7=0.26) (8=0.20) INTO AF1 .
END IF .

DO IF (alc1 = 16 & sex = 1) .
RECODE
agegp
(2=0.05) (3=0.05) (4=0.04) (5=0.05) (6=0.05) (7=0.04) (8=0.03) INTO AF1 .
END IF .

DO IF (alc1 = 17 & sex = 1) .
RECODE
agegp
(2 thru 4=0.08) (5=0.09) (6=0.08) (7=0.07) (8=0.05) INTO AF1 .
END IF .

Given there are 45 conditions and 14 diagnosic fields, the programs end up huge if I paste and copy each program 14 times to process each diagnostic field. I was wondering if there's a command I can use at the beginning of each program to say 'do the following for diag 1 to 14 / alc 1 to 14.'

Hope this has made it clearer. It's very difficult to explain programming in English!

Kind regards,

Liz


Top
 Profile  
 
 Post subject: Iterative analysis solved, trailing Xs not!
PostPosted: Thu Jan 22, 2009 2:32 pm 
Offline

Joined: Tue Jan 20, 2009 10:28 am
Posts: 4
Hey guys,

I think I’ve solved how to do the iterative analysis I posted a question about a couple of days ago. Just thought I’d share the solution in case anyone else has the same problem.

For the first program the syntax is:

DO REPEAT diag = diag1 TO diag14
/alc = alc1 TO alc14.

[put the IF statements here]

END REPEAT.

For the second program I just replaced diag with alc, and alc with af in the syntax above.


On another topic, if anyone reading this can tell me why the following code doesn’t remove trailing Xs from my data file, I’d be very grateful. I posted this query in the Enhancing Data section earlier. The syntax works for dashes but not Xs. Weird!

string newerdiag (A6).
compute newerdiag = RTRIM(newdiag, 'X').
execute.

Thanks.

Liz


Top
 Profile  
 



Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Template made by DEVPPL

This site is in no way connected with SPSS Inc. or any affiliate of SPPS Inc. The SPSS logo and products are owned by and copyrighted by SPSS Inc. The views expressed in the messages posted on this site are those of persons writing those comments and not necessarily those of the SPSSforum.com. SPSSforum.com does not vouch for the accuracy or truthfulness of any posted statement or opinion. The SPSSforum.com has, however, refrained from posting any item containing any statement known to be inaccurate, false or baseless.