I have a basic dataset where values in variable A are grouped into categories in variable B.
to do a quick check that the classification is working correctly, I could do a simple proc freq, but all the zero counts work against quick visual discernment. So proc tabulate is better. Call me pedantic, though, but I want to tabulate the Ns without the decimal.
I thought that BESTDw.d would work (https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001263753.htm ) but it doesn't.
Any suggestions?
data have;
input A B;
datalines;
25 2
16 2
11 1
13 1
17 2
14 2
23 2
18 2
21 2
23 2
21 2
14 2
13 1
19 2
12 1
17 2
25 2
24 2
14 2
14 2
18 2
22 2
14 2
16 2
13 1
12 1
6 1
12 1
14 2
18 2
7 1
6 1
13 1
9 1
15 2
14 2
10 1
20 2
25 2
5 1
11 1
32 3
26 2
22 2
23 2
21 2
18 2
33 3
;;
run;
proc format; picture nozero low--1,1-high=BESTD4. 0,.=" ";run;
proc tabulate data=have;
class a b;
table a, b*N=" "*f=nozero./row=float;
run;
Thanks Tom.
I think if you had run my code, you would have seen, but your point did help me realise the flaw in my thinking (or is that, over-thinking):
proc format; picture nozero 0,.=" ";run;
So all I had to do was not specify a format for anything other than zeros or missings.
I don't understand. If you use the normal numeric format without specifying a number of decimal places it will not show the decimal point.
For example if the integers are between 99,999 and -9,999 you could use the format 5.
1240 data _null_; 1241 do i=-9999,-1 to 2,100,1000,10000,99999; 1242 put i 5.; 1243 end; 1244 run; -9999 -1 0 1 2 100 1000 10000 99999
What do you want that is different?
Thanks Tom.
I think if you had run my code, you would have seen, but your point did help me realise the flaw in my thinking (or is that, over-thinking):
proc format; picture nozero 0,.=" ";run;
So all I had to do was not specify a format for anything other than zeros or missings.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.