Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Extracting value labels

1,713 views
Skip to first unread message

michael...@hotmail.com

unread,
Jan 30, 2008, 10:36:35 PM1/30/08
to
I have an SPSS file with a variable that has a large number of value
labels. I need to create another variable that uses these value
labels but with different values. Is it possible to generate a text
format of the value labels for a variable? I tried to use data
dictionary to export the value labels but with version 16 the text
format separates all values with hyphens between each line. It is nice
looking format but hard to parse. This function creates a summary for
all the variables and not just a particular variable.

Any suggestions?

Mark Ebermann

unread,
Jan 31, 2008, 6:39:45 AM1/31/08
to
On Wed, 30 Jan 2008 19:36:35 -0800 (PST), michael...@hotmail.com
wrote:

File->Display Data File Information??

peter m sopp

unread,
Jan 31, 2008, 7:07:50 AM1/31/08
to
Mark Ebermann schrieb:
DISPLAY DICTIONARY /VAR=VariableIwantInformationAbout.

Until know I have no experience with v16.0.1 - use the export function
to excel or editor, modify it, export it back. Maybe this is helpful.
Peter

michael...@hotmail.com

unread,
Jan 31, 2008, 9:22:15 AM1/31/08
to
On Jan 31, 7:07 am, peter m sopp <p...@gmx.net> wrote:
> Mark Ebermann schrieb:> On Wed, 30 Jan 2008 19:36:35 -0800 (PST), michael_427...@hotmail.com

Thank you for the suggestions. The File>Display Data File Information
displays information for all variables and not just a particular
variable as does 'DISPLAY DICTIONARY /
VAR=VariableIwantInformationAbout.'. It is annoying that when I save
the table to a text file, it contains formatting. It would have
better if it just generated a flat file. But I did what Peter
suggested and save it to excel, modified it and exported it back.

Again thanks.

JKPeck

unread,
Jan 31, 2008, 11:52:53 AM1/31/08
to

The easiest way to do this is to use OMS to capture the value label
table with OMS. That gives you many choices for the output format,
including a sav file, plain text, html, and xml, and you can limit the
output to just the value labels table.

Another way would be with a small Python program that reads the value
labels and writes them to a file under any format you want.

HTH,
Jon Peck

Jim

unread,
Feb 1, 2008, 10:25:39 AM2/1/08
to
> Jon Peck- Hide quoted text -
>
> - Show quoted text -

i'm probably not understanding the problem but why not use the
VALUELABEL(VAR_NAME) deal? like in this:
string newvar (a12).
compute newvar = valuelabel(month).
exe.
freq newvar.

then edit values? Jim Watts

Bruce Weaver

unread,
Feb 1, 2008, 1:36:47 PM2/1/08
to

I hadn't spotted the VALUELABEL function before. That's neat. Here's
a little demo.

* --------------------------------------------------- .
* Demonstration of the VALUELABEL function.
* Write value labels for OLDVAR into a string
* variable called LABELVAR. Then list OLDVAR
* and LABELVAR to get the guts of the VALUE
* LABELS command I want to apply to another
* set of variables.
* --------------------------------------------------- .

* Note that in SPSS 16, the sample datasets are in
* ..\SPSS\Samples\. If you are using an older
* version, the file is likely in the main SPSS folder.

GET
FILE='C:\Program Files\SPSS\Samples\1991 U.S. General Social
Survey.sav' /
keep = sex to region prob1.

freq prob1.

string labelvar (a50).
numeric new1 to new99 (f1.0).
compute labelvar = concat('"',valuelabel(prob1),'"').
exe.
sort cases by prob1.
match files
file = * /
by prob1 /
first = first
.
temp.
select if first.
list prob1 labelvar.

* Copy that listing from the output window and
* paste into the syntax window; use it as the
* main part of the value labels command.

value labels new1 to new99
1 "Health"
2 "Finances"
3 "Lack of Basic Services"
4 "Family"
5 "Personal"
7 "Miscellaneous"
.

* Add some data to NEW1 and NEW99, and test.

compute new1 = prob1.
compute new99 = prob1.
freq new1 new99.

* --------------------------------------------------- .
* Bruce Weaver, bwe...@lakeheadu.ca .
* 01-Feb-2008 .
* --------------------------------------------------- .

--
Bruce Weaver
bwe...@lakeheadu.ca
www.angelfire.com/wv/bwhomedir
"When all else fails, RTFM."

0 new messages