Wietze314
Wietze314

Reputation: 6020

How to stop truncation of strings at 255

I have problems exporting long string variables from SAS to SPSS.

DATA testString;
INPUT testString $ 300.;
testLength=LENGTH(testString);
DATALINES;
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
;
RUN;

PROC EXPORT
DATA=WORK.teststring
FILE="H:/TestSPSStrucation.sav"
DBMS=SAV
REPLACE;

When I open the exported SPSS file, the string is truncated at 255 characters. I have tried different things like changing the dbms to SPSS or mixing the formats. Without much result.

The SPSS file that is generated, testString variable is type String and has Width 765. There is no issue adding characters to the variable to get a wider string than 255 characters.

Upvotes: 1

Views: 2301

Answers (3)

JKP
JKP

Reputation: 5417

SPSS has supported string variables up to 32K in length for quite a while now. You might try using the SPSS procedure to read the SAS file directory. File > Open or, in syntax, GET TRANSLATE.

Upvotes: 0

Joe
Joe

Reputation: 63424

As of SAS 9.4, according to the documentation, SAS supports a maximum of 256 bytes (characters) for character variables when exporting to SPSS. My guess would be that this was a limitation of an older SPSS version that was current when SAS developed the SPSS export engine.

SPSS is capable of importing directly from a SAS dataset (a .sas7bdat), and that may be the better way to get around this.

Upvotes: 2

Jacob Ian
Jacob Ian

Reputation: 699

I think you can fix this by expanding the character variable padding (CVP) engine. Try a libname statement with the option CVPBYTES = #bytes you need?

Upvotes: 0

Related Questions