Modifying SPSS data export

Plus d'informations
il y a 4 semaines 19 heures #189012 par Matadeleo
Hi guys,

I'm trying to improve the export for multi-choice questions, so it's easier to use in tabulation software. Here is the goal:



In the /admin/export controller, I can only find code used to generate an SPSS syntax file.

I've managed to remove the Value Label for "Not selected", and instead of using the label "Selected" I pull in the actual label using the code below:
// Print out the value labels!
echo "VALUE LABELS  {$field['id']}\n";
 
$i = 0;
foreach ($answers as $answer) {
	$i++;
 
	if ($field['SPSStype'] == "F" && isNumericExtended($answer['code'])) {
		$str = "{$answer['code']}";
	} else {
		$str = "\"{$answer['code']}\"";
	}
 
	// If multi-choice, use variable label as value label
	$title = $field['VariableLabel'];
	preg_match("/\[(.*)\]/", $title , $matches);
	$valueLabel = $matches[1];
 
	if ($i < count($answers)) {
		echo ($field['LStype'] == "M" ? " $str \"{$valueLabel}\"\n" : " $str \"{$answer['value']}\"\n");
	} else {
		if ($field['LStype']=="M") {
			echo ($answer['code'] == 0 ? ".\n" : " $str \"{$valueLabel}\".\n");
		} else {
			echo " $str \"{$answer['value']}\".\n";
		}
	}
}

This gets us to the "current output", but as you can see, we still have the 0 values in the data (editing the export file only affects the labels).

Is there a way to remove the 0 values on multi-choice questions?

Connexion ou Créer un compte pour participer à la conversation.

LimeSurvey Partners
Plus d'informations
il y a 4 semaines 17 heures #189014 par jelo
Réponse de jelo sur le sujet Modifying SPSS data export
I recommend to place a feature request into the Bugtracker. There are not many users here using SPSS, but the feature request will help to raise awareness.

Did you try to use a few lines of SPSS Syntax to change the cell content.
Modifying the core php code might be a bit tricky with all the updates.

What version of LimeSurvey do you use?

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 semaines 17 heures - il y a 4 semaines 17 heures #189017 par Matadeleo
Réponse de Matadeleo sur le sujet Modifying SPSS data export
Build: Version 3.17.16+190906

Looking at previous builds, this particular code seems unchanged since as far back as 2.0 and maybe earlier

There is maybe the possibility of inserting syntax code where the software generates the labels, but that would be a messy, hacky solution. Ideally we would not generate the zeros for multi-choice at all, rather than fixing them in post! :)

Something like this, before the execute command
// Untested code
foreach ($fields as $field) {
 	if $field['LStype'] == "M" {
		echo 'replace(' . $field['title'] . '),0,"")'.
	}
}


Would be good to see if this is feasible - I'm not comfortable in making a feature request
Dernière édition: il y a 4 semaines 17 heures par Matadeleo.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 semaines 16 heures #189019 par Joffm
Réponse de Joffm sur le sujet Modifying SPSS data export
Maybe I misunderstand, why you want to get a categorical output.
In SPSS you have to use multiple sets anyway.

So with the setting


I get this


a clean binary output which you can easily change to the categorical output by an SPSS "recode" or an EXCEL macro.

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 semaines 16 heures #189021 par Matadeleo
Réponse de Matadeleo sur le sujet Modifying SPSS data export
Hi Joffm,

The screenshot you linked is for Excel-export, that option is not available for SPSS export.

The categorical output as you say it, makes it much easier to create a multi-response set from the data in SPSS and in more specific tabulation software.

By default creating a multi-response set from the screenshotted data would create a variable with:

Selected (Q1_1/1)
Not selected (Q1_1/0)
Selected (Q1_2/1)
Not selected (Q1_2/0)
Selected (Q1_3/1)
Not selected (Q1_3/0)

And so on..

Having the data in the way I described would give the much cleaner:

Option 1 (Q1_1/1)
Option 2 (Q1_2/1)
Option 3 (Q1_3/1)

Yes, this could be achieved by exporting the data to SPSS and to excel like you mentioned, but to manually replace the data is time consuming.

My solution so far saves a lot of time creating multi-response sets, and works well, the last step is to get rid of the 0 values to have a clean data file.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 semaines 15 heures #189024 par holch
Réponse de holch sur le sujet Modifying SPSS data export

Looking at previous builds, this particular code seems unchanged since as far back as 2.0 and maybe earlier

Still, every update can overwrite this file. So either you won't update anymore or you check before every update if there have been any changes to this file. So there is always this risk. If you update manually, then you can always do this, but I guess it would be probably better if this would be adapted in the LS base, wouldn't it? I assume that this might be interesting for others that use SPSS as well.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 semaines 14 heures #189026 par Matadeleo
Réponse de Matadeleo sur le sujet Modifying SPSS data export
Every time we update LS, we rename the export file - run the update and then apply the "fix" to the new file.

It would be amazing to adapt it into the LS base, even if it was just a toggle option like Joffm linked above



I'm happy to keep manually applying the changes (and to update them if the core code changes), if anyone is able to help point me in the right direction to achieve this.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 semaines 5 jours - il y a 3 semaines 5 jours #189042 par Joffm
Réponse de Joffm sur le sujet Modifying SPSS data export
Sorry, but I do not see your problem.
This is the default SPSS-export.


Creating multiple sets you have the option to select (binary or catagorical)


And with two statements added to the syntax file before you read in the data.
RECODE G01Q01_SQ001 (1=1) (0=SYSMIS).
RECODE G01Q01_SQ002 (1=2) (0=SYSMIS).
RECODE G01Q01_SQ003 (1=3) (0=SYSMIS).
RECODE G01Q01_SQ004 (1=4) (0=SYSMIS).
RECODE G01Q01_SQ005 (1=5) (0=SYSMIS).

VALUE LABELS G01Q01_SQ001
1 "Option 1"
0 "".
VALUE LABELS G01Q01_SQ002
2 "Option 2"
0 "".
...


(I always adapt the syntax file to my needs. On this stage it is the easiest an quickest way.

Then you get



And:
The advantage of a binary export is that you get the frequencies of each item without multiple sets.
The advantage of a real categorical export would be that you have the order the items are selected.

But this is not supported by LimeSurvey.


Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Pièces jointes :
Dernière édition: il y a 3 semaines 5 jours par Joffm.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 semaines 4 jours #189052 par Indispirit
Réponse de Indispirit sur le sujet Modifying SPSS data export
Although it's not a LS fix, you could automate the Excel part by using a pivot table.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 semaines 4 jours #189054 par Matadeleo
Réponse de Matadeleo sur le sujet Modifying SPSS data export
Hi Joffm, of course this is possible through SPSS as you mentioned. Sorry if I was not clear - the idea is to avoid having to do this.

We don't need to recode it to be categorical, just trying to avoid exporting the zeros for multi-choice to begin with - to avoid the need to get all variables and recode the zeros as sysmis. This is purely to save time.

Connexion ou Créer un compte pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!