BookmarkSubscribeRSS Feed
deepanshu88us0
Fluorite | Level 6

I have output which has some leading and trailing spaces. I preserved it using asis= option. It's working but I also want to reduce the width of column (basically wrapping text). When I am using cellwidth=5in asis=ON] it is not considering cellwidth= option. I understand asis= is trying to show it as-is. I am not creating HTML file, only want to show output in RESULTS window.

 

data outdata;
  infile datalines;
  input;
  output = _infile_;
  datalines;
                                         This is a long line of data with leading and trailing space                                          
;
run;

 

proc report data=outdata ;
column output;
define output / display style(column)=[cellwidth=5in fontsize=10pt asis=ON];
run;

 

10 REPLIES 10
mtnbikerjoshua
Obsidian | Level 7

Hi @deepanshu88us0,

 

Just to be clear the asis=ON option preserves leading space but not trailing space. I tried your code with this example data, and the cellwidth= seems to be working as expected. Can you provide example data that reproduces the problem?

 

data outdata;
  infile datalines;
  input;
  output = _infile_;
  datalines;
                                         This is a long line of data with leading and trailing space                                          
;
run;

mtnbikerjoshua_0-1678220798949.png

deepanshu88us0
Fluorite | Level 6

It's not working..Not throwing error but not making changes.. Try with cellwidth=1in

 

proc report data=outdata ;
column output;
define output / display style(column)=[cellwidth=1in fontsize=10pt asis=ON];
run;

Note : I am using SAS Studio

deepanshu88us0_0-1678221748548.png

 

 

Cynthia_sas
SAS Super FREQ
Just FYI, unless you change the options, the RESULT window in SAS Studio is showing you HTML output. So in fact, you ARE using HTML.I believe the default is HTML5.
Cynthia
deepanshu88us0
Fluorite | Level 6

Thanks. any solution to the original problem?

mtnbikerjoshua
Obsidian | Level 7

Based on that bug report, it seems like your best bet would be to upgrade SAS if that is possible. If you can't, then one possible workaround is to make the first character of the string something that SAS doesn't recognize as a space. For instance, you could put a zero width space at the beginning of the string:

 

data outdata;
  infile datalines;
  input;
  output = _infile_;
  datalines;
^{unicode 0200B}                                       This is a long line of data with leading and trailing space                                          
;
run;

ods escapechar='^';

proc report data=outdata ;
column output;
define output / display style(column)=[cellwidth=5in fontsize=10pt];
run;
Cynthia_sas
SAS Super FREQ
Hi: No solution because the original problem is not clear to me. You want to have both leading and trailing spaces respected, but you also want to control the cellwidth to 5" and the font size to 10pt. I can't really visualize what you want because there's only 1 line of "data" in your initial program. And it doesn't really look like data to me, it looks like text strings. How do you envision being able to see the leading and trailing spaces in a line that wraps to a cellwidth of 5"? I would need to see more lines of output and some example of what you expect to get or what you want.
Cynthia
Ksharp
Super User
/*
Try option:
1)indent=0.5in
or
2)pretext=' '
*/
data outdata;
infile datalines;
input;
output = _infile_;
datalines;
This is a long line of data with leading and trailing space
;
run;
proc report data=outdata nowd;
column output;
define output / display style(column)=[cellwidth=1in fontsize=10pt indent=0.5in];
run;
deepanshu88us0
Fluorite | Level 6

Thanks. Identation is not consistent in my dataset.. Some obs may have larger identation than others, some may not even have any. 

KevinViel
Pyrite | Level 9

I like the style indent approach, especially since 1) it does not pad the value, which matters when another programmer must Validate the data sets, 2) if wrapping occurs the value does not start at the left most, but rather back at the margin, and 3) one can use logic in a COMPUTE block to apply it:

 

https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-PDF-RTF-and-the-REPORT-procedure-break-on-...

 

Specifically, I use

 

 

compute row_1 ;
   if row_order_1 > 0
   then call define ( _col_
                    , "style"
                    , "style = { leftmargin = 1% }"
                    ) ;

endcomp ;

 

 

HTH,

 

Kevin

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 10 replies
  • 2359 views
  • 1 like
  • 5 in conversation