i have proc means procedure as below. I want to modify it to show count of 0 values for each column.
or
is there any other proc that i could use that will provide me below for selected numeric columns in my dataset?
MEAN STD MIN MAX N NMISS 0count
data work.staff;
infile datalines dlm='#';
input Name & $16. IdNumber $ Salary
Site $ HireDate date7.;
format hiredate date7.;
datalines;
Capalleti, Jimmy# 2355# 21163# BR1# 30JAN09
Chen, Len# 5889# 20976# BR1# 18JUN06
Davis, Brad# 3878# 19571# BR2# 20MAR84
Leung, Brenda# 4409# 34321# BR2# 18SEP94
Martinez, Maria# 3985# 0# US2# 10JAN93
Orfali, Philip# 0740# 50092# US2# 16FEB03
Patel, Mary# 2398# 35182# BR3# 02FEB90
Smith, Robert# 5162# 40100# BR5# 15APR66
Sorrell, Joseph# 4421# 38760# US1# 19JUN11
Zook, Carla# 7385# 22988# BR3# 18DEC10
run;
PROC MEANS DATA=WORK.staff
FW=12
PRINTALLTYPES
CHARTYPE
VARDEF=DF
MEAN
STD
MIN
MAX
N
NMISS ;
VAR Salary HireDate;
RUN;
Checking Related topics to your post can be useful. Does this help?
https://communities.sas.com/t5/SAS-Procedures/PROC-FREQ-Include-Zero-Counts/m-p/325505#M62255
how could i include other statistics, like mean median mode max min etc along with count of 0s? i would like to have a single output table similar to proc freq
The simplest way would be to work with your data, creating a new variable:
if salary = 0 then _0_count = 0;
Now the N statistic for _0_count gives you a count of the zeros.
but that would mean that i have to create dummy column for each column in my data. I have 100+ columns and i cannot create dummy column for each
See if this gives you something usable.
proc format library=work;
value iszero
0='Yes'
other='No'
;
run;
proc tabulate data=have;
class _numeric_/missing;
format _numeric_ iszero.;
tables _numeric_ ,
n
;
run;
replace HAVE with the name of your data set.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.