Re: Flip command and string vars
Posted by
David Marso on
Nov 19, 2013; 4:55pm
URL: http://spssx-discussion.165.s1.nabble.com/Flip-command-and-string-vars-tp5723152p5723158.html
In all likelihood because FLIP is a brain-dead procedure and all the smart people were on vacation when they had the design meetings (FLIP is certainly pre 1990).
Hint Gene: Both VARSTOCASES and CASESTOVARS respect strings.
Furthermore they can use mixed length strings (setting the result to maximum).
In response to many angry callers and faxes, I created a 'workaround' in the early 90's using XSAVE in a loop followed by a VECTOR/AGGREGATE combo. IIRC it was a pain because VECTOR also requires same size strings. To make it flexible required building a new set of variables with a known max-size and tossing those into the XSAVE loop.
That is now happily long obsolete since VARSTOCASES and CASESTOVARS (circa 2000 or so).
DATA LIST FREE / a b (2A1) c d z (3A6).
BEGIN DATA
a b c d z
z d c b a
END DATA.
VARSTOCASES /ID=id /MAKE stack FROM a TO z /INDEX=oldvar(stack) .
ALTER TYPE id (a10).
COMPUTE id=CONCAT("Case_",LTRIM(id)).
SORT CASES BY oldvar id.
CASESTOVARS /ID=oldvar/INDEX=id /GROUPBY=VARIABLE.
Maguin, Eugene wrote
Given a dataset of only string vars of the same dimension, e.g., a5, I'm curious as to why the Flip command returns sysmis for the rearranged dataset. I understand that this is a very specific situation and maybe that's a good enough reason. And I understand why flip won't work for a mixed dataset of either strings and numeric or strings of varying dimensions.
Gene Maguin
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?"