Date: Fri, 5 Sep 2003 20:24:16 -0400
Reply-To: Raynald Levesque <rlevesque@videotron.ca>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Raynald Levesque <rlevesque@videotron.ca>
Subject: Re: Longer variable names: Ability to truncate to 8 chars when
importing from external database?
In-Reply-To: <sf58a14f.073@s_mail2.transport.nsw.gov.au>
Content-type: text/plain; charset=us-ascii
Hi Frank
Good point!
I did not hear that an option would exist to allow us to restric the
conversion to 8 chars.
However, the following macro could be used to automatically rename the new
(long names) to the former names.
* Create 2 data files for illustration purposes.
DATA LIST LIST /var1 var2 var3.
BEGIN DATA
1 2 3
END DATA.
SAVE OUTFILE='c:\temp\old names.sav'.
DATA LIST LIST /x y z.
BEGIN DATA
1 2 3
END DATA.
SAVE OUTFILE='c:\temp\new names.sav'.
******* Start job *********.
*///////////////////.
DEFINE !vname(old=!TOKENS(1) /new=!TOKENS(1))
GET FILE=!new.
N OF CASES 1.
FLIP.
COMPUTE nb=$CASENUM.
SAVE OUTFILE='c:\temp\new names2.sav' /RENAME=(case_lbl=newnames).
GET FILE=!old.
N OF CASES 1.
FLIP.
RENAME VARIABLES (case_lbl=oldnames).
COMPUTE nb=$CASENUM.
MATCH FILES FILE=*
/FILE='c:\temp\new names2.sav'.
WRITE OUTFILE='c:\temp\rename syntax.sps'
/"RENAME VARIABLES ("newnames"="oldnames").".
EXECUTE.
GET FILE=!new.
* Rename new variables to the former names.
INCLUDE 'c:\temp\rename syntax.sps'.
!ENDDEFINE.
*///////////////////.
* Example of use of the macro.
!vname old='c:\temp\old names.sav'
new='c:\temp\new names.sav'.
Regards
Raynald Levesque rlevesque@videotron.ca
Visit my SPSS site: http://pages.infinit.net/rlevesqu/
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On Behalf Of
Frank Milthorpe
Sent: September 5, 2003 12:44 AM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: Longer variable names: Ability to truncate to 8 chars when
importing from external database?
This is perhaps a question more for the SPSS staff.
I welcome the use of longer variable names, especially when importing
data from external sources eg databases and etc.
I am trying to understand the possible conversion implications that
this
may have. Currently we have a number of syntax files that import data
from external (Informix) databases using SQL and then undertake various
analysis tasks within SPSS. In the current environment the database
variable names are automatically truncated to 8 characters. It is these
truncated 8 character variable names that are used in SPSS syntax that
we
have written.
With version 12, it is my understanding that longer names will be
possible. Will the SQL process allow the user a choice (eg via some
type
of parameter) as to whether the variable names are truncated? If not, I
suspect that it will be necessary insert some RENAME VARIABLES syntax
to
allow me to continue to use the existing syntax.
Has this issue been raised and discussed somewhere? If so, can someone
please direct me to the appropriate site?
Regards
Frank Milthorpe
--------------------------------------------
Frank Milthorpe
Transport Modelling Manager
Transport Data Centre
Department of Infrastructure, Planning and Natural Resources
GPO Box 1620, Sydney NSW 2001
Level 17, 227 Elizabeth St, Sydney
Tel: +61 2 9268 2937
Fax: +61 2 9268 2853
Email: frank.milthorpe@transport.nsw.gov.au