BookmarkSubscribeRSS Feed
lisa2002
Fluorite | Level 6

Hello everyone, 

 

I have a large dataset that I'm working on and I'm trying to figure out how to exclude all ages and only count the ages of men that are 75 years old.  Still learning, if someone could assist that would be great.

 

/*how many men are 75 years old*/

 

Age BMI

74     30.6

74     25.9

74     31.2

75     28.1

75     32.9

75     32

75     23.7

75     25

80     22.4

80    28.4

80     27.2

 

This is my code...clearly I don't want to sum up the ages so this is not working.  I need a count of all the men that are 75yrs. and not sure how to receive only those numbers.

 

proc sql;
create table Men75yrs as
select *, sum(Age) as yrs75total
from sashelp.bmimen
Quit;

 

 

 

3 REPLIES 3
novinosrin
Tourmaline | Level 20
data have;
input Age BMI;
cards;
74     30.6
74     25.9
74     31.2
75     28.1
75     32.9
75     32
75     23.7
75     25
80     22.4
80    28.4
80     27.2
;

proc sql;
create table want as
select age, count(age) as count
from have
where age=75
group by age;
quit;
lisa2002
Fluorite | Level 6

Thank you so much! 

PaigeMiller
Diamond | Level 26
proc freq data=have;
    table age;
run;

or

 

proc freq data=have(where=(age=75));
    table age;
run;

 

 

 

 

PROC FREQ is a fundamental tool that all SAS users should be familiar with.

--
Paige Miller

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 510 views
  • 3 likes
  • 3 in conversation