Untangling string multiple responses jammed into one variable

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Untangling string multiple responses jammed into one variable

Art Kendall
This post was updated on .
This converstaion started as the topic
 "SPSSINC trans gives error message in SPSS 27 syntax worked in SPSS 24:
but was getting long.

This the example syntax,

* Encoding: UTF-8.
data list list /How_Store_Water (a120).
begin data
"barrel|covered bucket without a tap"
"plastic container|jug|jerry can"
"does not store drinking water"
"covered bucket without a tap|plastic container|jug|jerry can"
"plastic container|jug|jerry can"
"covered bucket without a tap"
"missing unknown reason"
"cistern|polytank|plastic container|jug|jerry can"
"does not store drinking water"
"plastic container|jug|jerry can"
"plastic container|jug|jerry can"
"plastic container|jug|jerry can"
"plastic container|jug|jerry can"
"plastic container|jug|jerry can"
"plastic container|jug|jerry can"
"plastic container|jug|jerry can"
"plastic container|jug|jerry can"
"barrel"
"covered bucket without a tap"
"covered bucket with tap"
"covered bucket without a tap"
"covered bucket without a tap"
"covered bucket with tap"
"missing unknown reason"
"barrel|covered bucket without a tap|plastic container|jug|jerry can"
"covered bucket without a tap"
"covered bucket without a tap"
"barrel"
"covered bucket without a tap"
"plastic container|jug|jerry can"
"plastic container|jug|jerry can"
"covered bucket without a tap"
"barrel"
"covered bucket with tap"
"barrel"
"covered bucket with tap"
"covered bucket without a tap"
"plastic container|jug|jerry can"
"barrel|cistern|polytank|pila or tina|uncovered bucket without a tap|covered
bucket without a tap|covered bucket with tap"
"i purchase water as needed"
"plastic container|jug|jerry can"
"covered bucket without a tap"
"barrel"
"does not store drinking water"
"covered bucket without a tap"
"covered bucket with tap"
"clay|ceramic jar"
"plastic container|jug|jerry can"
"covered bucket with tap"
"uncovered bucket without a tap|plastic container|jug|jerry can"
end data.
FREQUENCIES variables= How_Store_Water.
begin program python3.
def astr(item, sep=" "):
    return str.split(item, sep)
end program.
spssinc trans result = T_Store_Water01 to T_Store_Water12 type=35
    /formula "astr(How_Store_Water, '|')".
execute.

DATASET ACTIVATE xDataset3.
* Define Multiple Response Sets.
MRSETS
  /MCGROUP NAME=$Text_Water_Storage LABEL='ways to store water'
VARIABLES=T_Store_Water01
    T_Store_Water02 T_Store_Water03 T_Store_Water04 T_Store_Water05
T_Store_Water06 T_Store_Water07
    T_Store_Water08 T_Store_Water09 T_Store_Water10 T_Store_Water11
T_Store_Water12
  /DISPLAY NAME=[$Text_Water_Storage].


* Custom Tables.
CTABLES
  /VLABELS VARIABLES=$Text_Water_Storage DISPLAY=NAME
  /TABLE $Text_Water_Storage [C][COUNT F40.0]
  /CATEGORIES VARIABLES=$Text_Water_Storage ORDER=A KEY=VALUE EMPTY=EXCLUDE
  /CRITERIA CILEVEL=95.




-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (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
Art Kendall
Social Research Consultants