Hi SAS community!
Regarding getting some standard statistics number, I usually proc sort then using proc means to do so.
My data is as below (I also attached a datafile contains one sample of my whole dataset). While Type indicates the companies, Country is 2-digit of country. My column of interest is amihud. The dataset included contains data from a lot of different countries. What I want is to receive some data statistics summary for each country containing: median, mean, p1, p5, p90, p95, p99 of variable amihud (especially it is good if the code relates to proc means)
Many thanks in advance!
Type year amihud Country
772086 1989 . AR
982616 1989 . AR
982620 1989 . AR
982629 1989 . AR
982694 1989 . AR
992128 1989 . AR
992156 1989 . AR
992183 1989 . AR
992260 1989 . AR
992280 1989 . AR
772086 1990 . AR
982616 1990 . AR
982620 1990 . AR
982629 1990 . AR
982694 1990 . AR
992128 1990 . AR
992156 1990 . AR
992183 1990 . AR
992260 1990 . AR
992280 1990 . AR
772086 1991 . AR
You show an example where AMIHUD is always missing. I assume that's not always the case. So this ought to work (but I can't test it).
proc summary nway data=have;
class country;
var amihud;
output out=_stats_ mean=/autoname;
run;
Where @PaigeMiller has the Mean= you would place ALL of your desired statistics:
median= mean= p1= p5= p90= p95= p99= /autoname ;
The autoname will append the statistic name to the variable so you can tell which stat is which in the data set.
You may want the option NWAY on the proc statement or you will get a summary overall across all countries as well.
Good catch, @ballardw
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
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.
Ready to level-up your skills? Choose your own adventure.