Date: Mon, 22 Aug 2005 13:38:23 +0200
Reply-To: Spousta Jan <JSpousta@CSAS.CZ>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Spousta Jan <JSpousta@CSAS.CZ>
Subject: Re: question about a macro
Content-Type: text/plain; charset="iso-8859-7"
Hello Stelios,
I do not think that you should create a macro for such a simple task: A one-line command is enough.
compute CHEK = (x <= maxX & x >= minX & y <= maxY & y >= minY).
But, if you need macros, you can write:
DEFINE MY_CHEK (ARG1 =!TOKENS(1)/A1_MIN = !TOKENS(1)/A1_MAX =!TOKENS(1)/ARG2 = !TOKENS(1)/ A2_MIN= !TOKENS(1)/ A2_MAX = !TOKENS(1)).
compute CHEK = !ARG1 <= !A1_MAX & !ARG1 >= !A1_MIN & !ARG2 <= !A2_MAX & !ARG2 >= !A2_MIN .
!enddefine.
(not tested but the principle should be correct)
Greetings
Jan
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of ???????? ???????
Sent: Monday, August 22, 2005 1:28 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: question about a macro
Hello everyone,
Let's say that I have a file with 2 variables X and Y.
Variable X (should) take only values 1 and 2, and Variable Y (should) take only values 1, 2, 3 and 4.
Let us, also, say that Variable Y should take values 1, 2,3 and 4, only when Variable X is equal to 1 or 2.
I have 100 cases in my file, and some of them have missing values for variable X, Y and some other cases have (wrong) values for Variable X,Y (for example, 8 or 9)
I want to create a macro to accomplish the following tasks:
1. Take 6 arguments: variable X, Variable Y, minimum_value_of_X, maximum_value_of_X, minimum_value_of_Y, maximum_value_of_Y.
2. Read my file, and for every case
chek if minimum_value_of_X <= X < =maximum_value_of_X,
and if minimum_value_of_Y <= Y <= maximum_value_of_X.
3. FOR EVERY case
If both the above conditions are true, compute Variable CHEK = 1
If one of the above is false, compute Variable CHEK = 0.
I have tried using a code like the next, but it did'nt work:
DEFINE MY_CHEK (ARG1 =!TOKENS(1)/ARG1_MIN = !TOKENS(1)/ARG1_MAX =!TOKENS(1)/ARG2 = !TOKENS(1)/ ARG2_MIN= !TOKENS(1)/ ARG2_MAX = !TOKENS(1))
!IF ((!ARG1 !LT !ARG1_MIN) !OR (!ARG1 !GT !ARG1_MAX) !OR
+ (!ARG2 !GT !ARG2_MAX) !OR(!ARG2 !LT !ARG2_MIN)))
!THEN
COMPUTE CHEK_TEST = 1.
!ELSE
COMPUTE CHEK_TEST = 0.
!IFEND.
!ENDDEFINE.
(After calling this macro, chek_test was equal to 1 for all cases)
Any ideas?
Stelios Zachariou
Διευκρίνιση
Οι πληροφορίες που περιέχονται σε αυτό το μήνυμα είναι εμπιστευτικές. Η ΕΣΥΕ δεν φέρει νομική ευθύνη για τα περιεχόμενα του μηνύματος, ή για τυχόν ζημιά από ιούς. Οι απόψεις που διατυπώνονται ανήκουν στον αποστολέα του μηνύματος και δεν εκφράζουν απαραίτητα τις απόψεις της ΕΣΥΕ Disclaimer The information in this e-mail is confidential. NSSG does not bear legal responsibility for the contents of this message or for any damage caused by viruses. Any opinions presented are those of the author and do not necessarily represent those of NSSG