BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mshelmike
Calcite | Level 5

Please help me out. I am trying to group Age variable say <10, 11-20, 30-40 and 40> and compute the number of occurence that falls within the range but I have been having challenge doing it. I am using the SAS studio

1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

 

You can do a frequency of AGE using proc freq.  But the problem is that it will tabulate individual age values, rather than the age groups of interest to you.

 

You could create a new variable, AGE_GROUP, calculated from AGE, and then get a frequency table of the new variable.  Or I recommend you create a format for AGE, which establishes age groups.  And then tell PROC FREQ to do a frequency of AGE using the format you have defined.

 

Have you set up the proc freq (without grouping) yet?  I recommend you show that code, and then we can be more useful in helping you.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

View solution in original post

2 REPLIES 2
mkeintz
PROC Star

 

You can do a frequency of AGE using proc freq.  But the problem is that it will tabulate individual age values, rather than the age groups of interest to you.

 

You could create a new variable, AGE_GROUP, calculated from AGE, and then get a frequency table of the new variable.  Or I recommend you create a format for AGE, which establishes age groups.  And then tell PROC FREQ to do a frequency of AGE using the format you have defined.

 

Have you set up the proc freq (without grouping) yet?  I recommend you show that code, and then we can be more useful in helping you.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
mshelmike
Calcite | Level 5

Thank you for the suggestion. I created AGE_GROUP, calculated from AGE, and then got a frequency table of the new variable.

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore Now →
Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 3693 views
  • 0 likes
  • 2 in conversation