SPSS Macro: compute by variable name -
SPSS Macro: compute by variable name -
i don't think spss macros can homecoming values, instead of assigning value vixl3 = !getlastavail target=vix level=3
figured need this:
/* computes lastly available entry of target @ given level */ define !complastavail(name !tokens(1) /target !tokens(1) /level !tokens(1)) compute tmpid= $casenum. dataset re-create tmpset1. select if not miss(!target). compute !name= lag(!target, !level). match files /file= * /file= tmpset1 /by tmpid. exec. delete variables tmpid. dataset close tmpset1. !enddefine. /* compute lastly values */ !complastavail name="vixcl3" target=vixc level=3.
the compute !name = ...
is problem is.
how should done properly? above returns:
>error # 4285 in column 9. text: vixcl3 >incorrect variable name: either name more 64 characters, or >not defined previous command. >execution of command stops.
when pass tokens macro, interpreted literally. when specify
!complastavail name="vixcl3"
it gets passed corresponding compute
statement "vixcl3"
, instead of variable name without quotation marks (e.g. vixcl3
).
two other general pieces of advice;
if command set mprint on
before execute macro, see how tokens passed macro. in instance, if had taken step, have seen offending compute statement , error message.
sometimes utilize quotation marks in tokens, , when case string commands !quote
, !unquote
come in handy.
macros spss
Comments
Post a Comment