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

I have this data:

 

Age  Pets  Country    height (cm)

35     3       US             165

65     2        UK            171

21     2        US            181

28     2        China       159

35     1        China       176

65     1        US             175

40    2         UK             178

 

And I want to summarize the variables using proc freq (so general summary statistics including n, mean,  median, std, q1, q3, min, max) by 3 groups, US, UK and China. A sample table is:

 

 

variable

 

Group

 

 

P-value

 

 

US

UK

China

 

age

 

 

 

 

 

 

n

 

 

 

 

 

mean

 

 

 

 

 

median

 

 

 

 

 

std

 

 

 

 

 

Q1, q3

 

 

 

 

 

Min,max

 

 

 

 

Height

 

 

 

 

 

 

n

 

 

 

 

 

 

 

 

 

 

The aesthetics can be different by methods and preferences but wanted to know how should I organize the data and merge them into this desired way (summary statistics for each variable in rows, by country in columns). Ideally I want to use proc report to generate the table but if it's too much, I want to know how to most efficiently merge the table at least. Thank you so much!! Discussion is welcomed

 

1 ACCEPTED SOLUTION
3 REPLIES 3
Astounding
PROC Star

A few points to begin.

 

PROC FREQ will probably not be part of the solution.  It doesn't compute the statistics you are hoping to display.

 

PROC TABULATE will do the job (and likely PROC REPORT as well, but I'm not as familiar with it).  And you won't need to manipulate the data ahead of time.

 

What procedure are you hoping to use to get p-values?  What do the p-values represent?  There's no way to include p-values in a program until you can address those questions.

 

Here's a shell of a program to get you going:

 

proc tabulate data=want;
class country;
var age height;
tables (age height) * (n mean median std q1 q3 min max),
  country;
run;
A_Kh
Barite | Level 11

Additionally, Proc Tabulate or Proc Report give descriptive stats in a different tabular format, not exactly the one you wanted (Min, Max or Q1, Q2 -  in the same cell). This requires a pre-processing of data. See the similar post here

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 1341 views
  • 2 likes
  • 4 in conversation