Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested formats in SAS are truncated to 40 characters when printing

If I create a format that includes a long label, it prints just fine. However, if I nest that format within a new format using square brackets, formatted values will be truncated to 40 characters upon printing.

I print this single value table two times, once using a normal format and once using a nested format. In both cases, I expect the formatted value to be the entire English alphabet twice in a row. However, the second time, when I use the nested format, it truncates the printed value to be only 40 characters long.

PROC FORMAT;
VALUE longfmt
    1 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
VALUE nestfmt
    1 = [longfmt.];
QUIT;

PROC SQL;
CREATE TABLE tbl (col NUM);
INSERT INTO tbl VALUES (1);

SELECT col FORMAT=longfmt. FROM tbl;
SELECT col FORMAT=nestfmt. FROM tbl;
QUIT;
like image 750
Nik Avatar asked Sep 03 '25 14:09

Nik


1 Answers

Thanks to Tom, I now understand I should have specified the width of the first format when I nested it in the second format. In other words, I changed [longfmt.] to [longfmt52.]:

PROC FORMAT;
VALUE longfmt
    1 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
VALUE nestfmt
    1 = [longfmt52.];
QUIT;

PROC SQL;
CREATE TABLE tbl (col NUM);
INSERT INTO tbl VALUES (1);

SELECT col FORMAT=longfmt. FROM tbl;
SELECT col FORMAT=nestfmt. FROM tbl;
QUIT;
like image 64
Nik Avatar answered Sep 05 '25 15:09

Nik