Hi,
I use a scratch variable in a recode. Then something strange happens. I will show that using both a scratch variable and a normal variable. I would expect that b and d have the same values. But b recieves a value when it should not have one. Everything works fine when there is an else clause, but I still do not understand what is happening. I have spss 20. Thanks Frans -------------------------- dataset close all. data list free/a. begin data end data. recode a(1=10)(2=20) into #c. compute b=#c. recode a(1=10)(2=20) into d. EXECUTE. list. a b d 1,00 10,00 10,00 2,00 20,00 20,00 1,00 10,00 10,00 2,00 20,00 20,00 1,00 10,00 10,00 2,00 20,00 20,00 3,00 20,00 . 4,00 20,00 . 5,00 20,00 . 6,00 20,00 . 1,00 10,00 10,00 2,00 20,00 20,00 |
Hi Frans, I think I understand what’s happening. Scratch variables in SPSS are not reinitialized when reading new cases. So, at the 7th case, the value of #c is still 20, carrying over from the 6th cases, where it was set to 20. In fact, it remains 20, until it is reset by a different value of A. Kind regards, Gerard van Meurs Evidens onderzoekdiensten BV Van: SPSSX(r) Discussion [mailto:[hidden email]] Namens Frans Marcelissen Hi, dataset close all. data list free/a. begin data 1 2 1 2 1 2 3 4 5 6 1 2 |
Administrator
|
"Scratch variables in SPSS are not reinitialized when reading new cases. "
Precisely! -- Why is is prudent to *ALWAYS* include a CYA clause in recodes: OTOH: In the posted example, one gains absolutely *NOTHING* by use of a scratch variable (except for an open invitation to a programming bug). -- data list free/a. begin data 1 2 1 2 1 2 3 4 5 6 1 2 end data. recode a(1=10)(2=20)(ELSE=SYSMIS) into #c. compute b=#c. recode a(1=10)(2=20)(ELSE=SYSMIS) into d. list.
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?" |
Free forum by Nabble | Edit this page |