Re: truncating long strings for print

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

Re: truncating long strings for print

Rick Oliver
If the issue is strings of varying length for the value of the same variable and you are writing out the contents of the data file to a text file, here's one way:

data list list /longstring (a20) numvar (f2).
begin data
a 1
aaa 2
aaaaa 3
aaaaaaaaa 4
aaaaaaaaaaaaa 5
end data.

SAVE TRANSLATE OUTFILE='C:\temp\test1.csv'
  /TYPE=CSV
  /REPLACE
  /FIELDNAMES
  /CELLS=VALUES.

Tab format probably gives similar results. If you don't want the comma (or other delimiter):

SAVE TRANSLATE OUTFILE='C:\temp\test1.csv'
  /TYPE=CSV
  /REPLACE
  /FIELDNAMES
  /CELLS=VALUES
  /TEXTOPTIONS DELIMITER=" ".

On Tue, Jan 8, 2019 at 9:29 AM Maguin, Eugene <[hidden email]> wrote:

I’m working with some long string (~a6000) data and have written it out to a txt file. The true length, i.e., trimmed length,  of the strings varies greatly from 0 to 5000+, which leads to a lot of useless, hard-to-read space in the text file. Previously, I used a for-profit editor, Multi-Edit, now a defunct company, to look at the files. ME had an extremely useful property in that at save it automatically stripped blanks from the end of lines, that is, lines were trimmed at save. I now use Notepad++, which I’ll come back to in a moment.

 

Using only spss is it possible to trim variables prior to write/print. I think the answer is NO but why not ask.

 

Onto Notepad++, which I think some number of people on this list use and like. Two questions. A) is it possible to get Notepad to trim lines at save? B) and assuming no useful answer to (a) how does one login to post a question? The “login” does nothing useful except offer facebook (corrupt company), a “cat”, google plus, and twitter as alternatives.

 

Thanks, Gene Maguin

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