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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

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
  • 1175 views
  • 0 likes
  • 2 in conversation