I have got this fairly large dataset, 600+ variables, where the labels for variables and values are all in Swedish. If
I would attempt to set up a new dataset with all labels in English, what would the best approach be? I can’t come up with anything better than a pretty tedious procedure: ·
GATHERMD to get a dataset with all variables
·
Export of the text in this dataset to some editor (or possibly Word or Excel) ·
Cut-and-paste operations into new syntax But there might be more clever ways to make such translations, so suggestions are more than welcome. Robert
Robert Lundqvist
|
Hi, Robert, you probably don't have a codebook that includes variable names and english labels. If you did you could generate the syntax with the help of Python and regex patterns.Otherwise you can 1. Create a text output that can be opened with Excel (there might be easier approaches) like so: * --------------------------------------------------------------------------------------------. FILE HANDLE path /NAME = 'yourDirectory' /* edit here */. BEGIN PROGRAM PYTHON. import spss, spssaux text = 'VariableName; VariableType; VariableLabel; Value; ValueLabel\n' for i in xrange(spss.GetVariableCount()): if spss.GetVariableType(i)==0: type = "Number" else: type = "Text" for j in sorted(spssaux.getValueLabels(i)): vlab = spssaux.getValueLabels(i).get(j) text += spss.GetVariableName(i) + " ;" + type + " ;" + str(spss.GetVariableLabel(i)) + " ;" + j + " ;" + vlab + "\n" print text syntax = '''OUTPUT EXPORT /CONTENTS EXPORT = VISIBLE /TEXT DOCUMENTFILE = 'path\myDictionary' ENCODING = UTF8. ''' spss.Submit(syntax) END PROGRAM. * --------------------------------------------------------------------------------------------. A text file "myDictionary.txt" is generated that can be renamed as *.csv and opened with Excel 2. Insert columns for English Variable Labels and Value labels and fill them. 3. Write Excel functions in additional columns to generate SPSS syntax from Excel fields. - VARIABLE LABELS ... - ADD VALUE LABELS ... *** Mario Giesel Munich, Germany
Am Montag, 27. Mai 2019, 09:09:08 MESZ hat Robert Lundqvist <[hidden email]> Folgendes geschrieben:
I have got this fairly large dataset, 600+ variables, where the labels for variables and values are all in Swedish. If I would attempt to set up a new dataset with all labels in English, what would the best approach be? I can’t come up with anything better than a pretty tedious procedure:
· GATHERMD to get a dataset with all variables · Export of the text in this dataset to some editor (or possibly Word or Excel) · Cut-and-paste operations into new syntax
But there might be more clever ways to make such translations, so suggestions are more than welcome.
Robert |
It seems like the time problem here is the translation. So, can a file of variable/value labels be run through a Swedish to English translation software such
that either a new file either listing the English version of each Swedish label or listing the Swedish version and a new column with the English translation? I’m thinking of google translate but I’ve never used it in that way.
The other thing that might be useful is either the Display command or the Codebook command. Display returns an object that can be turned into a tab-delimited
file and read back into spss. I seldom use the codebook command so I can say much about it. Mario has a nice python program but I’m pretty confident that the value labels can be reassembled and written out correctly using native spss code. The real problem,
to me, is the translation element. Gene Maguin From: SPSSX(r) Discussion <[hidden email]>
On Behalf Of Mario Giesel Hi, Robert, you probably don't have a codebook that includes variable names and english labels. If you did you could generate the syntax with the help of Python and regex patterns. Otherwise you can
Mario Giesel Munich, Germany Am Montag, 27. Mai 2019, 09:09:08 MESZ hat Robert Lundqvist <[hidden email]> Folgendes geschrieben:
I have got this fairly large dataset, 600+ variables, where the labels for variables and values are all in Swedish. If I would attempt to set up a
new dataset with all labels in English, what would the best approach be? I can’t come up with anything better than a pretty tedious procedure: ·
GATHERMD to get a dataset with all variables
·
Export of the text in this dataset to some editor (or possibly Word or Excel) ·
Cut-and-paste operations into new syntax But there might be more clever ways to make such translations, so suggestions are more than welcome. Robert ===================== To manage your subscription to SPSSX-L, send a message to
[hidden email] (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 ===================== To manage your subscription to SPSSX-L, send a message to
[hidden email] (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 |
In reply to this post by spss.giesel@yahoo.de
Another approach that might be a little less work would be this. 1. Run this code to generate two datasets for variable and value labels. dataset declare varinfo. dataset declare vallabels. oms select tables /if subtypes='Variable Information' /destination format=sav outfile=varinfo. oms select tables /if subtypes='Variable Values' /destination format=sav outfile=vallabels. display dict. omsend. 2. Using the Data Editor (widen the relevant column as needed), insert the translations. If you have a lot of duplicate values labels, e. g., for Yes and No, you can use the DE replace menu to do them all at once. 3. Save the two files and send them to me. I will write a short Python program that generates VARIABLE LABEL and VALUE LABEL syntax for these. On Mon, May 27, 2019 at 2:18 AM Mario Giesel <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |