Forcing Blanks with WRITE COMMAND

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Forcing Blanks with WRITE COMMAND

Juan Pablo Sandoval
Hi: I have a rather large dataset with I need to export to ASCII format, but
at some points I need to force blanks so I can conform to the client's
format. In order to do that at some points I need to "force" blanks, I have
variables in my dataset for that purpose, and I use this syntax:

write outfile = "C:\TEMP\TEST.DAT" /
var1 (f7)
blank (a40)
var2 (f2)
blank1 (a501)
var3 (f4).
...
exe.

And I get and error that says

"The field width is greater than the maximum permitted for the specified"
How can I force blank spaces of at fixed places in my syntax?

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Forcing Blanks with WRITE COMMAND

Richard Ristow
At 10:31 PM 3/16/2008, Juan Pablo Sandoval wrote:

>Hi: I have a rather large dataset with I need to export to ASCII
>format, but at some points I need to force blanks so I can conform
>to the client's
>format. In order to do that at some points I need to "force" blanks, I have
>variables in my dataset for that purpose, and I use this syntax:
>
>write outfile = "C:\TEMP\TEST.DAT" /
>   var1   (f7)
>   blank  (a40)
>   var2   (f2)
>   blank1 (a501)
>   var3   (f4).
>...
>exe.
>
>And I get an error that says
>"The field width is greater than the maximum permitted for the specified"

I'm not sure. To start with, have you declared blank1 as a
501-character string? Anyway, the following approach appears to work for me:

WRITE OUTFILE=WriteTo / var1(F7) var2(40X,F2) var3(501X,F4).

==================================
APPENDIX: All code, with test data
==================================
DATA LIST FREE /var1 var2 var3.
BEGIN DATA
1234567 22 4444.
END DATA.

WRITE OUTFILE=WriteTo
    /'Start of output, not a real record'.

WRITE OUTFILE=WriteTo / var1(F7) var2(40X,F2) var3(501X,F4).
EXECUTE.

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