Hi,
I am creating a demographic summary with almost 50 segments. Some of the categorical variables have percentage next to it.
For some of the variables, only need to display proc means results.
1: Is there any way to right allign the proc mean result by a decimal point and put it in a character column?
2: I am using picture format to adjust the percentage for the few segments and its working fine but again number before the percentage is not right alligned, how can I fix it.
Thanks,
There are ways to align decimals (style align=decimal for one). However if you want to see percentages - and in table outputs its normally count with percentage in brackets, it is far simpler to create a string variable output:
data want; set means_output; result1=cat(strip(put(n,best.)," (",strip(put(percent,6.2)),"%)"); run;
Then print the string value. In this way you can combine values, add strings, and output in many ways without complex formats or tricks.
picture percent (round)
0 ='( 0.0)' (noedit)
-1 <- < 0 =' 0.9)' (prefix='( ')
0 <- < 10 =' 9.9)' (prefix='( ')
10 - < 100 =' 99.9)' (prefix='( ')
100 = '(100)' (noedit)
;
If your ODS destination is RTF or PDF, Try:
style={just=dec}
Thats was the first thing I tired, but it didn't work.
Wondering if there is any format to change the character (number) variable so it looks exactly like numeric value (Left alligned) apart from decimal number, as they need to be alliged by decimal points?
@hira wrote:
Thats was the first thing I tired, but it didn't work.
Wondering if there is any format to change the character (number) variable so it looks exactly like numeric value (Left alligned) apart from decimal number, as they need to be alliged by decimal points?
Aligning text is always dependent on font. An alignment built for Courier will not match when displayed using Times New Roman (or any proportional font in general). If you do not have complete control of the font all the way through all of the processes, reports and displays intended then the work is wasted. Or you get to repeat any solution that might work at every step where the font changes.
Personally I suspect that extracting the numeric portion, assuming there is a numeric portion as otherwise "decimal" would be the incorrect term, so that could be aligned and play around with displays of the non-numeric.
Doesn't work is awful vague.
Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.
No output? Post any log in a code box.
Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.