LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2003)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 3 Feb 2003 06:24:51 +0100
Reply-To:   luca@lucameyer.com
Sender:   "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:   Luca Meyer <luca@lucameyer.com>
Organization:   http://www.lucameyer.com/
Subject:   R: A way to import variable labels
Comments:   cc: Raynald Levesque <rlevesque@videotron.ca>
In-Reply-To:   <JAEFJAPAEBFCDIHJIFKCOECMCMAA.rlevesque@videotron.ca>
Content-Type:   text/plain; charset="iso-8859-1"

Dear Raynald,

Thank you very much for your suggestion.

The code works indeed but I am left with 2 practical problems:

1) Some of the labels contain ' symbols (the text is in Italian), which causes the procedure to read the label only up to the first ' symbol

2) The lenght of the label is not a constant (it contains the text of a question), a matter that for the time being I have solved by imposing the vname string leght equal to 255 char, but that I would like to solve in a neater manner....

Thanks again for your suggestions.

Regards, Luca

> -----Messaggio originale----- > Da: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] Per > conto di Raynald Levesque > Inviato: marted́ 28 gennaio 2003 3.02 > A: SPSSX-L@LISTSERV.UGA.EDU > Oggetto: Re: A way to import variable labels > > > Hi > > Of course there is a way... > > * Create a sample text file with variables names in first line. > > DATA LIST FIXED /linestr 1-50(A). > BEGIN DATA > "var label 1" "var label 2" "var label 3" > 1 1 1 > 2 2 2 > 3 4 5 > 7 2 4 > END DATA. > LIST. > WRITE OUTFILE='c:\temp\test.txt'/linestr. > EXECUTE. > > * Get the variable labels. > GET DATA /TYPE = TXT > /FILE = 'C:\Temp\test.txt' > /DELCASE = LINE > /DELIMITERS = "\t " > /QUALIFIER = '"' > /ARRANGEMENT = DELIMITED > /FIRSTCASE = 1 > /IMPORTCASE = FIRST 1 > /VARIABLES = > V1 A11 > V2 A11 > V3 A11. > CACHE. > EXECUTE. > > > * Create syntax to define variable label. > STRING vname(A8). > DO REPEAT var=ALL. > DO IF var<>vname. /* we do not need a label for vname */ > - COMPUTE #vn=#vn+1. > - COMPUTE vname=CONCAT('v',LTRIM(STRING(#vn,F4))). > - WRITE OUTFILE 'c:\temp\define var labels.sps' > /"Variable Label "vname" '"var"'.". > END IF. > END REPEAT PRINT. > EXECUTE. > > > * get data. > GET DATA /TYPE = TXT > /FILE = 'C:\Temp\test.txt' > /DELCASE = LINE > /DELIMITERS = "\t " > /QUALIFIER = '"' > /ARRANGEMENT = DELIMITED > /FIRSTCASE = 2 > /IMPORTCASE = ALL > /VARIABLES = > V1 A11 > V2 A11 > V3 A11. > CACHE. > EXECUTE. > > * Define variable labels. > INCLUDE "c:\temp\define var labels.sps". > > Regards > > Raynald Levesque rlevesque@videotron.ca > Visit my SPSS Pages http://pages.infinit.net/rlevesqu/index.htm > > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On > Behalf Of Luca Meyer > Sent: January 27, 2003 10:18 AM > To: SPSSX-L@LISTSERV.UGA.EDU > Subject: A way to import variable labels > > > Hello, > > I have txt file with variable labels as first line of the > file. Is there a way to import them without having to retype > one-by-one using the VAR LABEL command? > > Thanks, > Luca > > Mr. Luca MEYER > Consumer research advisor > http://lucameyer.com/ > >


Back to: Top of message | Previous page | Main SPSSX-L page