spss 22 macro problem

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

spss 22 macro problem

ChetMeinzer
the code below works fine in 21, so any idea why it crashes in 22?

DEFINE DBstartdate() date.dmy(1,7,2011) !ENDDEFINE.
define OAkeepRU() "01EM1","01EI1" !enddefine.

get file='k:\epsCG.sav'  
select if any(ru,OAkeepRU).
select if Closdate ge DBstartdate or sysmis(closdate).


output says 'DBstartdate  not defined by previous command.
Reply | Threaded
Open this post in threaded view
|

Re: spss 22 macro problem

David Marso
Administrator
Works fine for me on ver 22.
Define Crash.
SPSS is saying that you have not ran the DEFINE.
Try again.

select if any(ru,OAkeepRU).
select if Closdate ge DBstartdate or sysmis(closdate).
SET MPRINT ON.
select if any(ru,OAkeepRU).
  48  0 M>  select if any(ru,'01EM1','01EI1'
  49  0 M>  ).
select if Closdate ge DBstartdate or sysmis(closdate).
  50  0 M>  select if Closdate ge date.dmy(1,7,2011)
  51  0 M>   or sysmis(closdate).

IMNSHO this is a silly use of macros.  
Better to parameterize a macro then have fragmented things you need to remember floating in the code.


ChetMeinzer wrote
the code below works fine in 21, so any idea why it crashes in 22?

DEFINE DBstartdate() date.dmy(1,7,2011) !ENDDEFINE.
define OAkeepRU() "01EM1","01EI1" !enddefine.

get file='k:\epsCG.sav'  
select if any(ru,OAkeepRU).
select if Closdate ge DBstartdate or sysmis(closdate).


output says 'DBstartdate  not defined by previous command.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: spss 22 macro problem

ChetMeinzer
David,
Enlighten me (i hate macros, but i'm willing to learn how to 'parameterize').  I came up with this so people (with less than skills) can change dates throughout syntax without digging through the file.  What else would work?


strange.  here is my output?  

select if opdate lt UnCookedMonth and (Closdate ge DBstartdate or sysmis(closdate)).
 682  0 M>  select if opdate lt UnCookedMonth and (Closdate ge DBstartdate or sysmis(closdate)).

Error # 4285 in column 52.  Text: DBstartdate
Incorrect variable name: either the name is more than 64 characters, or it is
not defined by a previous command.
Execution of this command stops.

Reply | Threaded
Open this post in threaded view
|

Re: spss 22 macro problem

David Marso
Administrator

DEFINE DBstartdate() date.dmy(1,7,2011) !ENDDEFINE.
define OAkeepRU() "01EM1","01EI1" !enddefine.

get file='k:\epsCG.sav'  
select if any(ru,OAkeepRU).
select if Closdate ge DBstartdate or sysmis(closdate).

I would rewrite that using parameterized macro as follows:
UNTESTED:

DEFINE !Getdates ( Keep !CHAREND ("/")
                    / BDStart !CHAREND ("/")
                    /   ClDate  !CHAREND ("/") !DEFAULT (Closdat)
                     / RuVar  !CHAREND ("/")  !DEFAULT (ru)      ).
select if any(!ruBar, !Keep).
select if !ClDate ge !BDStart or sysmis(!Cldate).
.........
!ENDDEFINE.
GET FILE .......
!GetDates KEEP="01EM1","01EI1"
             / BDStart= date.dmy(1,7,2011)
             / ClDATE= Closdate
             / ruVar = ru.

Could also be invoked as:
!GetDates KEEP="01EM1","01EI1"    / BDStart= date.dmy(1,7,2011).

ChetMeinzer wrote
David,
Enlighten me (i hate macros, but i'm willing to learn how to 'parameterize').  I came up with this so people (with less than skills) can change dates throughout syntax without digging through the file.  What else would work?


strange.  here is my output?  

select if opdate lt UnCookedMonth and (Closdate ge DBstartdate or sysmis(closdate)).
 682  0 M>  select if opdate lt UnCookedMonth and (Closdate ge DBstartdate or sysmis(closdate)).

Error # 4285 in column 52.  Text: DBstartdate
Incorrect variable name: either the name is more than 64 characters, or it is
not defined by a previous command.
Execution of this command stops.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: spss 22 macro problem

Mario Giesel
In reply to this post by ChetMeinzer
Possibly a closing dot is missing?!
 
get file='k:\epsCG.sav'
 
Mario


ChetMeinzer <[hidden email]> schrieb am 23:12 Freitag, 1.November 2013:
David,
Enlighten me (i hate macros, but i'm willing to learn how to
'parameterize').  I came up with this so people (with less than skills) can
change dates throughout syntax without digging through the file.  What else
would work?


strange.  here is my output?
*
select if opdate lt UnCookedMonth and (Closdate ge DBstartdate or
sysmis(closdate)).
682  0 M>  select if opdate lt UnCookedMonth and (Closdate ge DBstartdate
or sysmis(closdate)).

Error # 4285 in column 52.  Text: DBstartdate
Incorrect variable name: either the name is more than 64 characters, or it
is
not defined by a previous command.
Execution of this command stops.*




--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/spss-22-macro-problem-tp5722852p5722863.html

Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


Mario Giesel
Munich, Germany