BookmarkSubscribeRSS Feed
HitmonTran
Pyrite | Level 9

Hi,

New to SAS.  I need to create a table, that shows total count across all variables and across all obs.  I am stuck on how to get that, thanks.

data (where Age_Group 1= 18-50yo,  Age_Group 2=51-65yo  ,  Age_Group 3= 65+yo):

 

Site    Age     Age_Group
1 18 1
1 18 1
1 18 1
2 20 1
2 55 2
2 55 2
3 55 2
3 70 3
3 75 3

 

 

want (table shell):

HitmonTran_0-1608167128115.png

 

 

 

3 REPLIES 3
Reeza
Super User

Have you tried using PROC TABULATE? That will likely get you the closest to the image shown.

 

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=proc&docsetTarget=n128ae2...

 


@HitmonTran wrote:

Hi,

New to SAS.  I need to create a table, that shows total count across all variables and across all obs.  I am stuck on how to get that, thanks.

data (where Age_Group 1= 18-50yo,  Age_Group 2=51-65yo  ,  Age_Group 3= 65+yo):

 

Site    Age     Age_Group
1 18 1
1 18 1
1 18 1
2 20 1
2 55 2
2 55 2
3 55 2
3 70 3
3 75 3

 

 

want (table shell):

HitmonTran_0-1608167128115.png

 

 

 


 

HitmonTran
Pyrite | Level 9
how do i get the %?
Reeza
Super User
Example 12 shows the methods to calculate the percentages. If you want it formatted EXACTLY as shown you have to manually create that table via pre-calculations and then display it using PROC REPORT.

Here's a way to get the data but you'll then need to use PROC REPORT to display the data.
https://gist.github.com/statgeek/0c4aeec9053cf8050be18a03b842c1b9

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1083 views
  • 0 likes
  • 2 in conversation