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;
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;
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
Thanks. any solution to the original problem?
Seems to be a bug - https://support.sas.com/kb/15/617.html
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;
Thanks. Identation is not consistent in my dataset.. Some obs may have larger identation than others, some may not even have any.
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:
Specifically, I use
compute row_1 ;
if row_order_1 > 0
then call define ( _col_
, "style"
, "style = { leftmargin = 1% }"
) ;
endcomp ;
HTH,
Kevin
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.