Exporting Value Labels to Excel Worksheets

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

Exporting Value Labels to Excel Worksheets

ariel barak
Fellow Users,
I'm running SPSS 16.0.1 on Windows XP.

I found some code on the listserv a while ago that exports spss data
directly into specific excel files and worksheets. However, I am having
issues when I try to save the value labels instead of the cell values. The
first save translate command below creates the test.xls file and writes and
creates a worksheet called test1 and writes directly to it. Even though I
have the /CELLS=LABELS, the resulting file has the two digit string values
instead of the race labels, with no errors encountered. The second save
translate command is the resulting code of when I select the "Save value
labels where defined instead of data values" when I save the data as an
Excel 1997-2003 file. The second save translate command writes the value
labels, which is what I want.

Does anybody know why the second command saves the labels while the first
one doesn't?

Any help will be greatly appreciated!

-Ari

*Sample Data.
DATA LIST LIST /id(F8) Race (A3) datein(ADATE) dateout(ADATE).
BEGIN DATA
1 32 12/5/2007 2/9/2008
2 42 2/7/2008 3/7/2008
3 32 3/2/2008 5/25/2008
4 55 2/1/2008 4/4/2008
5 56 1/31/2008 4/1/2008
END DATA.

VALUE LABELS Race
'32' 'Black - Not Hispanic'
'42' 'White - Not Hispanic'
'55' 'Hispanic'
'56' 'Other'
'66' 'Unknown'.

SAVE TRANSLATE
/CONNECT='DSN=Excel
Files;DBQ=C:\Temp\test.xls;DriverId=790;MaxBufferSize=2048;PageTimeout=5;'
/TABLE="test1"
/TYPE=ODBC
/MAP
/REPLACE
/CELLS=LABELS.
EXE.

SAVE TRANSLATE OUTFILE='C:\Temp\test v2.xls'
  /TYPE=XLS
  /VERSION=8
  /MAP
  /REPLACE
  /FIELDNAMES
  /CELLS=LABELS.

=====================
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