The SAS Output Delivery System and reporting techniques

wrap text

Reply
SAS Employee
Posts: 105

wrap text

Hi,

Is there a way to wrap long text in:

  • sas data:

for  example:  data a;

                    x="aaaaaaaaaa";

                   run;

       i want the output of the cell in the data will be like :

                    aaaaa

                    aaaaa

  • ODS HTML somthing like the  flow option that is good for ods listing

Thanks in advanced

SAS Super FREQ
Posts: 8,864

Re: wrap text

Hi:

  The FLOW option of PROC REPORT is only a LISTING destination option. Most ODS destinations ignore the FLOW option (among others). If you adjust cellwidth, and if your text string has a place to break, you can sometimes use only cellwidth (as shown in SHORTVAR2 and with both the LONGVAR and LONGVAR2 columns in the program output below. But, notice how with SHORTVAR, even with a ridiculously small value for CELLWIDTH, the text string does not wrap. You can control EXACTLY where your string will wrap in a cell, by inserting a "carriage return/line feed" ODS ESCAPECHAR command, as shown for the SHORTVAR_NL variable. See the attached screenshot for how the output looks.

cynthia

data longtxt;

  length longvar $270

         shortvar $12 shortvar2 $13 shortvar_nl $25;

  set sashelp.class(obs=2);

  shortvar = 'aaaaaaaaaaaa';

  shortvar2 = 'aaaaaa aaaaaa';

  shortvar_nl = 'aaaaaa~{newline 1}aaaaaa';

  longvar = catx(' ','Twas brillig and the slithy toves.',

                 'Did gyre and gimble in the wabe',

                 'All mimsy were the borogroves',

                 'And the mome raths outgrabe.',

                 'Beware the Jabberwock my son',

                 'The jaws that bite, the claws that snatch.',

                 'Beware the jubjub bird and shun',

                 'the frumious Bandersnatch.');

  longvar2 = longvar;

run;

ods listing close;

ods html file='c:\temp\use_cellwidth.html'

    style=sasweb ;

  ods escapechar='~';

             

  proc report data=longtxt nowd;

    column name shortvar shortvar2 shortvar_nl longvar longvar2;

    title '1) Really LONG char var wraps based on cellwidth';

    define name / display style(column)={just=c};

    define shortvar/ display

           style(column)={cellwidth=.10in};

    define shortvar2/ display

           style(column)={cellwidth=.10in};

    define shortvar_nl/display;

    define longvar/ display

           style(column)={cellwidth=2in};

    define longvar2/display

           style(column)={cellwidth=4in};

  run;

ods _all_ close;

title; footnote;


use_cellwidth.jpg
SAS Employee
Posts: 105

Re: wrap text

Posted in reply to Cynthia_sas

Hi Cynthia,

Thank you very much for your detailed answer that you provide with great generosity

Smiley Happy

Ask a Question
Discussion stats
  • 2 replies
  • 477 views
  • 0 likes
  • 2 in conversation