[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Austin Nichols" <austinnichols@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Length for strings, ignoring SMCL tags |

Date |
Tue, 2 Dec 2008 18:11:20 -0500 |

Brian Karfunkel <bkarfunkel@gmail.com>: Do you need the {smcl} in there? Can you use string display formats instead? di %~18s "Hello" %~10s "World" _n %~18s "Really abnormally long cell value" Sorry to not be more constructive, but I still can't see where you're coming from or going to. On Tue, Dec 2, 2008 at 4:43 PM, Brian Karfunkel <bkarfunkel@gmail.com> wrote: > Thanks for the help so far, it's at least nice to know I'm not > overlooking something that's easy. > > I'm trying to output a series of locals in a nice tabular format, with > pipes (i.e. "|") between columns and a line of hyphens separating > rows. So, I iterate through a list of rows and columns, etc., and > ultimately have a string that contains the text for each row. For a > 2X2 with Hello, World, Longval, and a blank as values that would be > something like: > > local row1 "| Hello{col 10} | World{col 18} |" > local row2 "| Longval{col 10} | {col 18} |" > > which outputs to: > > | Hello | World | > | Longval | | > (note that in fixed-char font the column dividers line up). > > The point is, the width of each column is set by the longest value in > that column. However, if, say, only one value in a column is very > long, I don't want to have that whole column be very wide, but rather > want something like this as output: > > -------------------- > | Test | Table | > -------------------- > | tst2 | Table | > ------------------------------------------------------------- > | Really abnormally long cell value | Table | > ------------------------------------------------------------- > | Test | Table | > -------------------- > > The problem is getting the right number of hyphens to be displayed; I > want as many hyphens in the row-separators as there are characters in > the output row, which is just the length of the row as it is > displayed. I can work around it by keeping track of the length of each > component of the output row (e.g. "Test" is 4, " | " is 3, "Table" is > 5, etc.), but I was hoping there was a less cumbersome way, though it > doesn't seem that there is. > > Anyway, thanks again for the help. > > -Brian * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Length for strings, ignoring SMCL tags***From:*"Brian Karfunkel" <bkarfunkel@gmail.com>

**Re: st: Length for strings, ignoring SMCL tags***From:*"Austin Nichols" <austinnichols@gmail.com>

**RE: st: Length for strings, ignoring SMCL tags***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: Length for strings, ignoring SMCL tags***From:*"Brian Karfunkel" <bkarfunkel@gmail.com>

- Prev by Date:
**Re: st: ranking with weights** - Next by Date:
**Re: st: tips on reading large matrix from ASCII file?** - Previous by thread:
**RE: st: Length for strings, ignoring SMCL tags** - Next by thread:
**Re: st: Length for strings, ignoring SMCL tags** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |