Dear colleagues!
I would be grateful if some of you tells me how could I save a .sav - file as a TXT-file with a delimiter - different from Space or TAB. For example with "|" as a delimiter. Thank you in advance! With the best regards: Boika Mileva |
You could try this:
Write outfile='newfile.txt' /1 var1 "|" var2 "|". ...and so on. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Boika Mileva Sent: Sunday, December 03, 2006 4:40 PM To: [hidden email] Subject: Save As TXT-File with "|" - delimiter? Dear colleagues! I would be grateful if some of you tells me how could I save a .sav - file as a TXT-file with a delimiter - different from Space or TAB. For example with "|" as a delimiter. Thank you in advance! With the best regards: Boika Mileva |
In reply to this post by Boika Mileva
This should work:
SAVE TRANSLATE /OUTFILE = 'file.txt' /TYPE = CSV /TEXTOPTIONS DELIMITER = '|'. Boika Mileva wrote: > Dear colleagues! > > I would be grateful if some of you tells me how could I save a .sav - file > as a TXT-file with a delimiter - different from Space or TAB. For example > with "|" as a delimiter. > > Thank you in advance! > > With the best regards: > > Boika Mileva > > Daniel Robertson Senior Research and Planning Associate Institutional Research and Planning Cornell University, Ithaca NY, 14853-2801 [hidden email] / ph:607.255.9642 |
In reply to this post by Boika Mileva
Thank you, Daniel, but it doesn't work for SPSS 11.5. Probably it works
for higher versions... With kind regards: Boika |
In reply to this post by Boika Mileva
Thank you very much, Craig! It does work! Is there a way to write the
variable names as a first line of the output file? Thank you in advance! With kind regards: Boika |
In reply to this post by Boika Mileva
Hi Boika
I have access to 11.5 too, on a Linux system Before the write outfile command you use to write the data itself, put this: do if ($casenum=1). write outfile='newfile' /1 "var1","|" "var2","|" end if. ...expanding that variable list as long as is necessary This says "for the first case only, write these strings of text to the file". So, you'll get a single header row in your file that looks like this: var1|var2| ...printed one time only to the file, followed by the data printed to the same file for all records using the write outfile command sent earlier. Side note: If you need a list of all variables in the file, try using: display labels. This will generate a long list of variable names followed by the labels. Using your tool of choice (vim is mine), parse out the variable names, and attach the quotes, pipes, etc. Makes writing this faster/easier. Also, make sure you do NOT have an execute or proc(edure) of any kind between the two write outfile commands. If you do, the second write outfile command will overwrite, rather than append to, newfile. Craig -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Boika Mileva Sent: Tuesday, December 05, 2006 4:12 AM To: [hidden email] Subject: Re: Save As TXT-File with "|" - delimiter? Thank you very much, Craig! It does work! Is there a way to write the variable names as a first line of the output file? Thank you in advance! With kind regards: Boika |
In reply to this post by Boika Mileva
One way is to do something like:
STRING bar (A1) . COMPUTE Bar = '|' . WRITE Outfile='mydata.txt' /1 Var1 Bar Var2 Bar (etc) . You may want to add WRITE FORMATS to better control output format. Dennis Deck, PhD RMC Research Corporation [hidden email] -----Original Message----- From: Boika Mileva [mailto:[hidden email]] Sent: Sunday, December 03, 2006 1:40 PM Subject: Save As TXT-File with "|" - delimiter? Dear colleagues! I would be grateful if some of you tells me how could I save a .sav - file as a TXT-file with a delimiter - different from Space or TAB. For example with "|" as a delimiter. Thank you in advance! With the best regards: Boika Mileva |
In SPSS 15 (but not earlier releases):
data list free /var1 var2 var3. begin data 1 2 3 4 5 6 end data. save translate outfile='c:\temp\mydata.txt' /type=csv /textoptions delimiter="|". -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Dennis Deck Sent: Tuesday, December 05, 2006 12:46 PM To: [hidden email] Subject: Re: Save As TXT-File with "|" - delimiter? One way is to do something like: STRING bar (A1) . COMPUTE Bar = '|' . WRITE Outfile='mydata.txt' /1 Var1 Bar Var2 Bar (etc) . You may want to add WRITE FORMATS to better control output format. Dennis Deck, PhD RMC Research Corporation [hidden email] -----Original Message----- From: Boika Mileva [mailto:[hidden email]] Sent: Sunday, December 03, 2006 1:40 PM Subject: Save As TXT-File with "|" - delimiter? Dear colleagues! I would be grateful if some of you tells me how could I save a .sav - file as a TXT-file with a delimiter - different from Space or TAB. For example with "|" as a delimiter. Thank you in advance! With the best regards: Boika Mileva |
In reply to this post by Boika Mileva
Thank you very much for your sugesstions and detailed explanations! Thanks
to all of you I solved my problem! With the best wishes! Boika |
Free forum by Nabble | Edit this page |