- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have the following data
DATA HAVE;
input year dz $8. area;
cards;
2000 stroke 08
2000 stroke 06
2000 stroke 06
;
run;
After using the proc tabulate
proc tabulate data=have;
class area dz;
table area, dz*(n colpctn);
run;
I get the below output
I want to replace any values below 5 in "N" column and 0 in "ColPctN" column with "<5" and "0", respectively.
I have the below proc format code
proc format;
picture count (round)
0-4 = ' <5' (NOEDIT);
picture pcnt (round)
0 = ' - '
other = '009.9%';
But I am not understanding how to use it in the data step to get the desired results. Please guide.
Thanks!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Refer to the documentation for the procedures you are trying to use to see what options they support.
For PROC FREQ just send the counts to a dataset and then print the dataset.
proc freq data=have;
tables area * dz / noprint out=counts;
run;
proc print data=counts;
format count fcount. percent pcnt. ;
run;.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Next code demonstrates the usage of format in proc tabulate:
DATA HAVE;
input year dz $8. area;
cards;
2000 stroke 08
2000 stroke 06
2000 stroke 06
;
run;
proc format;
picture count (round)
0-4 = ' <5' (NOEDIT);
picture pcnt (round)
0 = ' - '
other = '009.9%';
run;
proc tabulate data=have;
class area dz;
table area, dz*(n*f=count. colpctn*f=pcnt.);
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc freq data=have;
tables area * dz / list nocum (frequency=fcount. percent=pcnt.);
run;.
But it doesn't work!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
With proc freq try - though I am sceptic about variable names to use:
proc freq data=have;
format frequency fcount. percent pcnt.;
tables area * dz / list nocum ;
run;.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I get the following in the log
36 proc freq data=have;
37 format frequency count. percent pcnt.;
WARNING: Variable FREQUENCY not found in data set WORK.HAVE.
WARNING: Variable PERCENT not found in data set WORK.HAVE.
38 tables area * dz / list nocum ;
39 run;
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Refer to the documentation for the procedures you are trying to use to see what options they support.
For PROC FREQ just send the counts to a dataset and then print the dataset.
proc freq data=have;
tables area * dz / noprint out=counts;
run;
proc print data=counts;
format count fcount. percent pcnt. ;
run;.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc format;
picture count (round)
0-4 = ' <5' (NOEDIT);
picture pcnt (round)
0 = ' - '
other = '009.9%';
proc tabulate data=have;
class area;
tables area=' ' all='Total',
n='Frequency' pctn='Percent'
/box=area;
run;
I have tried using the following but its not working
proc tabulate data=have;
class area;
tables area=' ' all='Total',
({n*f=count.}='Frequency') ({pctn*f=pcnt.}='Percent')
/box=area;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, it is possible. Change proc tabulate line to:
n='Frequency'*f=count. pctn='Percent'*f=fpcnt.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content