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 2003)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 30 Oct 2003 11:08:52 -0600
Reply-To:     "Marks, Jim" <Jim.Marks@lodgenet.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         "Marks, Jim" <Jim.Marks@lodgenet.com>
Subject:      Re: Other problems with a Macro (long)
Content-Type: text/plain; charset="iso-8859-1"

Salut Yves:

have you tried running the large macro with "SET MPRINT = YES." This will print out the expanded macro (i.e. the commands that the macro is passing to SPSS for action). The exact structure of your DO IF loops will be available to check.

Bonne chance

Jim Marks Senior Market Analyst LodgeNet Entertainment Corporation

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On Behalf Of Yves Therriault Sent: Thursday, October 30, 2003 8:15 AM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Other problems with a Macro (long)

Hello to all SPSSers,

Last week, I sent this list a message in which I explained that I've written 3 macros in order to automatically compute standard mortality ratios, their 95 % confidence intervals for the 6 Municipalités régionales de comté (Regional County Municipality) of our region. I'm using the indirect standardized method with the crude death rates of the province of Quebec for each age categories (20 categories).

The first macro, called nb_tx has been written to compute the total number of deaths observed over a period of x years (andeb, anfin) for each of the 6 MRCs, the North Shore region and the province of Quebec; the mean number of deaths per year and the crude mean death rate per year, for specific causes of mortality (cause and CIM1 CIM2 CIM3 CIM4) for each age categories. The macro was also written to allow the computation of SMRs for women, men and whole population (Pop = "Population masculine", "Population féminine", and "Population totale"). The original macros are working very well (I've never wrote macros before since I just began very recently to learn macro language). However, I need to improve those macros in order allow the computation of a global SMR.

I order to discover which section(s) of the macro is(are) wrong, I enclosed parts of them between "Define and !Enddefine" commands and test them.

Note :********************************.

Arguments "CIM1 to CIM4" are related to the values of the variable Q9. They represent codes taken from ICD-9 ("International classification of diseases and related health problems).

When the argument "cause" has values ranging from 1 to 16, the cause of death is taken from variable Q9. However, I gave this argument the value 17 when the death is related to specific codes of the ICD-9 (800 to 959). In such a case, the macro looks for the codes in the variable Q12 instead of Q9 accordingly to values given to the arguments "trm1 to trm4". The variable Q12 has a missing value whenever the ICD doesn't vary from 800 to 959. Finally, the argument (cause = 20) has been defined for situations when I need to compute a global SMR (standardized mortality ratio) i.e without a specific cause of mortality in mind.

***************************************************************.

For example :

* //////////////////////////////////////////////////////////////////.

Define !nb_tx (andeb = !tokens(1) / anfin = !tokens(1) / cause = !tokens(1) / cim1 = !tokens(1) / cim2 = !tokens(1) / cim3 = !tokens(1) / cim4 = !tokens(1) / trm1 = !tokens(1) / trm2 = !tokens(1) / trm3 = !tokens(1) / trm4 = !tokens(1) / nb_ans = !tokens(1) / denom = !tokens(1) / nm_caus = !Charend("/") / anpop = !tokens(1) / pop = !Charend("/") / nom_fic = !Charend("/"))

do if (!pop = "Population masculine" and Q8 = "M"). - compute sex = 1. - else if (!pop = "Population féminine" and Q8 = "F"). - compute sex = 1. - else if (!pop = "Population totale" and ANY(Q8,"M","F","I")). - compute sex = 1. - else if (Q8 = "I"). - compute sex = 0. end if. exec.

do if ((!cause >= 1 and !cause < 17) and Q10 = !cause). - compute deces = 1. - else if ((!cause = 17) and Q10 = !cause). - compute deces = 2. - else if (!cause = 20). - compute deces = 3. end if. exec

This section of the code is working fine when I test the macro.

For example :

!nb_tx andeb=94 anfin=98 cause=2 pop="Population totale"/.

or

!nb_tx andeb=94 anfin=98 cause=17 pop="Population féminine"/.

But when I add this part to the macro :

do if (deces = 1). - do if (q9 >= !cim1 and q9 < !cim2) or (q9 >= !cim3 and q9 < !cim4). - compute filtre = 10. - else. - compute filtre = 0. - end if. - else if (deces = 2). - do if ((~missing(q12)) and ((q12 >= !trm1 and q12 < !trm2) or (q12 > = !trm3 and q12 < !trm4))). - compute filtre = 10. - else. - compute filtre = 0. - end if. - else if (deces = 3) - do if (q9 >= !cim1 and q9 < !cim2) or (q9 >= !cim3 and q9 < !cim4). - compute filtre = 10. - else. - compute filtre = 0. - end if. - else. - compute filtre = 0. end if. exec.

select if (sex = 1 and filtre = 10). exec.

I always get this message :

>Error # 4024 in column 37. Text: AND >The sequence of operators found is invalid. Check the expression for >omitted or extra operands, operators, and parentheses. >This command not executed.

>Error # 4055. Command name: ELSE IF >The ELSE IF command does not follow an unclosed DO IF command. Maybe the >DO IF command was not recognized because of an error. Use the >level-of-control shown to the left of the SPSS commands to determine the >range of LOOPs and DO IFs. >This command not executed.

>Error # 4068. Command name: ELSE >The ELSE command does not follow an unclosed DO IF command. Maybe the DO >IF command was not recognized because of an error. Use the >level-of-control shown to the left of the SPSS commands to determine the >range of LOOPs and DO IFs. >This command not executed.

>Error # 4070. Command name: END IF >The command does not follow an unclosed DO IF command. Maybe the DO IF >command was not recognized because of an error. Use the level-of-control >shown to the left of the SPSS commands to determine the range of LOOPs and >DO IFs. >This command not executed.

>Error # 4068. Command name: ELSE >The ELSE command does not follow an unclosed DO IF command. Maybe the DO >IF command was not recognized because of an error. Use the >level-of-control shown to the left of the SPSS commands to determine the >range of LOOPs and DO IFs. >This command not executed.

>Error # 4070. Command name: END IF >The command does not follow an unclosed DO IF command. Maybe the DO IF >command was not recognized because of an error. Use the level-of-control >shown to the left of the SPSS commands to determine the range of LOOPs and >DO IFs. >This command not executed.

The section : do if (deces = 1) is working fine. The problem begins with this section of the code : else if (deces = 2). Yet, if I test only this section with a "do if" clause, like do if (deces = 2) ... instead of a "else if" [without including the clause do if (deces = 1)], this section works.

I would appreciate very much if some of you could help me to understand what is going wrong with this code.

Thanks in advance,

P.S. I hope you won't have too much difficulties to understand my poor English grammar and syntax.

Yves Therriault, Ph. D. Agent de recherche Régie régionale de la santé et des services sociaux de la Côte-Nord Tél. : (418) 589-9845 Téléc. : (418) 589-8574 Courriel : Yves_Therriault@ssss.gouv.qc.ca __________________________________________________


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