Good morning,
I was wondering whether there is a countif function like the one in Excel that can count across rows...
Have
| Mary |
| Mary |
| Mary |
| Jim |
| Jim |
| Jim |
| Jim |
| Jim |
| Steven |
| Steven |
Want
Mary | 3 |
| Jim | 5 |
| Steven | 2 |
Thank you!
PROC FREQ.
Proc freq data=sashelp.class;
Table Age/Out=Age_Categories;
run;
PROC FREQ.
Proc freq data=sashelp.class;
Table Age/Out=Age_Categories;
run;
You also can use PROC SQL or PROC MEANS:
proc sql;
create table want as
select distinct name,
count(name) as count_names
from have
group by name;
quit;
proc means data=have;
class name;
output out=want
(where=name ne ' '
drop=_type_
rename=_freq_=count_names);
run;
Check the documentation regarding the NWAY option and you won't need the where data set option.
Also check out TYPES and WAYS statements.
Proc Freq! Of course! ![]()
Thank you.
I wish i knew how to use sql. I keep on bumping to it. It is on my list!
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 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.
Ready to level-up your skills? Choose your own adventure.