|
hullo list
I have been working with macros for some time but just ran into a bug.
I have written a macro that generates data from a population with specific parameters. One parameter is a correlation I introduce between two variables. I specify weights for combining two random variables to form a new variable.
Program runs fine unless I specify the weight as a negative value.
The issue seems to be that the negative value is not being passed from the macro call line into the macro.
..not sure if this is unique to v 17 because in all my prior work I have never tried this.
Has anyone had similar problem? If so, can you recommend a solution?
_____________________________________________________________
Jason W. Beckstead, Ph.D.
Associate Professor/Quantitative Methodologist
University of South Florida College of Nursing
12901 Bruce B. Downs Blvd., MDC22, Tampa, FL 33612, USA
phone: +1.813.974.7667 fax: +1.813.974.5418
|
|
Hi
Jason,
Although it
references some different error numbers, I believe resolution 80373 provides the
answer:
While a
blank is the "most common" token delimiter, it's not the only one. Minus
signs, among other things, are defined as tokens in and of themselves. So
this:
-6
Even with no
space in between them would be read as two separate tokens: - and
6.
So the only
way to submit a negative number as a token parameter is to use something other
than !Positional -- !ENCLOSE, for example:
define vars4
(!pos !enc('<','>')/!pos !enc('<','>')/!pos !enc('<','>')/!pos
!enc('<','>')).
compute
int=!1.
compute bt=!2. compute bbde=!3. compute btxbde=!4. !enddefine.
vars4
<96> <-.76> <-5.4> <1.9>.
exe.
Or you could use !CHAREND: define vars4 (!pos
!charend('/')
/!pos !charend('/') /!pos !charend('/') /!pos !charend('/')). compute int=!1. compute bt=!2. compute bbde=!3. compute btxbde=!4. !enddefine. vars4 96/ -.76/ -5.4/ 1.9/. exe. Or. you can still use !POS if you quote the token. But then you have to !UNQUOTE the token in the macro definition: define vars4 (!pos !tok(1)/!pos !tok(1)/!pos !tok(1)/!pos !tok(1)). compute int=!UNQUOTE(!1). compute bt=!UNQUOTE(!2). compute bbde=!UNQUOTE(!3). compute btxbde=!UNQUOTE(!4). !enddefine. vars4 '96' '-.76' '-5.4' '1.9'. That works as well.
David Nichols
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Beckstead, Jason Sent: Tuesday, March 31, 2009 12:38 PM To: [hidden email] Subject: [SPSSX-L] passing negative value into macro causes error 4024 hullo list
I have been working with macros for some time but just ran into a
bug.
I have written a macro that generates data from a population with specific
parameters. One parameter is a correlation I introduce between two variables. I
specify weights for combining two random variables to form a new variable.
Program runs fine unless I specify the weight as a negative value.
The issue seems to be that the negative value is not being passed from the
macro call line into the macro.
..not sure if this is unique to v 17 because in all my prior work I have
never tried this.
Has anyone had similar problem? If so, can you recommend a solution?
_____________________________________________________________
Jason W. Beckstead, Ph.D.
Associate Professor/Quantitative Methodologist
University of South Florida College of Nursing
12901 Bruce B. Downs Blvd., MDC22, Tampa, FL 33612, USA
phone: +1.813.974.7667 fax:
+1.813.974.5418
|
| Free forum by Nabble | Edit this page |
