Hi
I want to use the LEAVE and AGGREGATE commands on a dataset but under some
conditions the dataset will be empty. In these cases I want to bypass these
commands as otherwise I get errors, and so I need to test if the dataset is
empty. One way of doing this is to use the !NULL macro command.
The original code is (this works perfectly when I have a proper
dataset)
*******************************************************************************************************************
DEFINE !no_int_types (type_1 = !TOKENS(1)
/type_2 = !TOKENS(1)
/type_3 = !TOKENS(1))
IF (LAG(equip_no, 1) NE equip_no) !CONCAT('cum_no_', !type_1, '_',
!type_2) = 0.
COMPUTE !CONCAT('cum_no_', !type_1, '_', !type_2) = !CONCAT('cum_no_',
!type_1, '_', !type_2) + (!CONCAT(!type_1, '_int_2') * !type_3).
LEAVE !CONCAT('cum_no_', !type_1, '_', !type_2).
EXECUTE.
AGGREGATE
/OUTFILE=* MODE=ADDVARIABLES
/BREAK=equip_no
/no_ints=MAX(!CONCAT('cum_no_', !type_1, '_', !type_2)).
!ENDDEFINE.
!no_int_types type_1=proact
type_2=non_terms_ttf type_3=non_term_event_ttf.
*******************************************************************************************************************
I put in the !NULL command in an !IF !THEN !IFEND condition as shown
below, but unfortunately this is completely ignored so I still get an error
message.
(type_3 is a numeric (scale) variable.)
*******************************************************************************************************************
DEFINE !no_int_types (type_1 = !TOKENS(1)
/type_2 = !TOKENS(1)
/type_3 = !TOKENS(1))
!IF (!type_3 !NE !NULL) !THEN
IF (LAG(equip_no, 1) NE equip_no) !CONCAT('cum_no_', !type_1, '_',
!type_2) = 0.
COMPUTE !CONCAT('cum_no_', !type_1, '_', !type_2) = !CONCAT('cum_no_',
!type_1, '_', !type_2) + (!CONCAT(!type_1, '_int_2') * !type_3).
LEAVE !CONCAT('cum_no_', !type_1, '_', !type_2).
EXECUTE.
AGGREGATE
/OUTFILE=* MODE=ADDVARIABLES
/BREAK=equip_no
/no_ints=MAX(!CONCAT('cum_no_', !type_1, '_', !type_2)).
IFEND
!ENDDEFINE.
!no_int_types type_1=proact
type_2=non_terms_ttf type_3=non_term_event_ttf.
*******************************************************************************************************************
I would be grateful if someone could explain what I am doing wrong. Thank
you.
Dr Atai Winkler
|
Free forum by Nabble | Edit this page |