BookmarkSubscribeRSS Feed
yonib
SAS Employee

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

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

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
yonib
SAS Employee

Hi Cynthia,

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

Smiley Happy

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2733 views
  • 0 likes
  • 2 in conversation