

There are times when a string may be too long to reasonably display inside a cell and so it would be nice to 'shrink it to fit' a defined column width in lieu of having the column width expand to accommodate the long string. so a reasonable solution (code below).īut, the ideal solution is still to somehow make the excel column width 'behave' the same as when you manually 'right click on entire column' / format / alignment / 'shrink to fit.' Does anyone know if this is doable ? (result needs to be output to excel)
#Excel adjust column width to fit text full#
This does allow - dynamically - the excel output to show the full column header when the variable length is smaller than it OR reduce the column width when the 'cell content' is shorter than the header. dah) did help to trigger a solution for using the larger of the variable name length (the excel column header) or the variable value length (the excel 'cell content'). Your response (of course " max(length(VAR))". Click on the option ‘Autofit Column Width.’ With these steps, you can immediately make the column expand to have the text in the cells appropriately adjusted. Click on the Home tab Check out the Cells group and then click on the option ‘Format.’ The drop-down will show the added options. Select length into : length_var separated by ','įor my current business purpose, wrapping the text is not ideal but if anyone has observations about that as well, I'll take it. Choose the column that you want to autofit. (this might conceivable allow all 'cell content' and/or 'column headers' to be visible in all circumstances). Ii) the width (# of chars) of the 'column header'. I) the given length of the SAS variable OR If not possible to 'shrink to fit', is it possible to find the 'longer of': Header_8='123' /*length=3 #of chars in header=8 */ĭefine var8 / style(column)= /* ? 'shrink to fit' so that variable value of length 8 fits column width of 4 */ĭefine header_8 / style(header)= /* ? 'shrink to fit' so that variable 'header' of length 8 chars fits column width of 4 */ Utilizing ODS Excel and/or PROC REPORT, want to make column width 'behave' like excel format / alignment / 'shrink to fit.' Is this even possible? (see attached.
