DATA Step, Macro, Functions and more

Aligning values in a table with different formats

Reply
Occasional Contributor den
Occasional Contributor
Posts: 16

Aligning values in a table with different formats

Hi all,

I'm creating a table output using proc tabulate and proc template. The table is a population demographic report. The rows are the various demographics and the column has the output statistical values. See example below:

Variable Stat Value
Age n 200
mean 62.1
std 9.35

Gender n 200
female 100 (50%)
male 100 (50%)

I would like to align the values in the third column so that they appear with decimal points aligned eg

Age n 200
mean 62.1
std 9.35

Gender n 200
female 100 (50%)
male 100 (50%)

I've tried justifying the column both to the left and right neither of which aligns the decimal point. When I justify using the decimal alignment, d, all of the decimals align but this causes the (%) statistic to right align rather than the count (100) aligning with the decimal point eg

Age n 200
mean 62.1
std 9.35

Gender n 200
female 100 (50%)
male 100 (50%)

Any advice on this issue would be much appreciated.
Super User
Posts: 10,516

Re: Aligning values in a table with different formats

Your post got bitten by the forum options. You're going to have to work much harder to imply alignment as tabs and such don't work well and it uses a proportional font so spaces may not work quite as expected either.
Example:

111
OOO

It might help to show your table code to see which approaches you were attempting and which output destination is needed.
Super User
Posts: 9,682

Re: Aligning values in a table with different formats

You can check format Dw.p and Bestd.



Ksharp
Occasional Contributor den
Occasional Contributor
Posts: 16

Re: Aligning values in a table with different formats

I got it sorted. In the end I had to create an extra column for the (%) and shorten the space between the count value and the (%) value.

Thanks
Ask a Question
Discussion stats
  • 3 replies
  • 193 views
  • 0 likes
  • 3 in conversation