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

Hi there,

For your kind information, I am trying to create a report where the mean, median and P90 will be presented for each month as follows:  

 

year                 jan                                      feb                                  mar                         apr              

                 mean median p90         mean median p90    mean median p90     mean median p90    

2011          2           3         7             3           4        8        4           5        7            3        5       7       

 

My current table as follows:

data have;
input year month $ mean median p90 ;
cards;
2011 jan 2 3 7
2011 feb 3 4 8
2011 mar 4 5 7
2011 apr 3 5 7
2011 may 3 6 8
2012 jan 3 5 7
2012 feb 3 6 8
2012 apr 3 5 7
2012 may 3 6 8
;
run;

Thank you in advance for your kind help.

Regards,

 

Swain
1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

proc tabulate will do the job, with some help to get the month order correct:

 

proc format;
value m
1 = "January"
2 = "February"
3 = "March"
4 = "April"
5 = "May";
run;

data have;
input year month $ mean median p90 ;
m = whichc(month, "jan", "feb", "mar", "apr", "may");
format m m.;
drop month;
cards;
2011 jan 2 3 7
2011 feb 3 4 8
2011 mar 4 5 7
2011 apr 3 5 7
2011 may 3 6 8
2012 jan 3 5 7
2012 feb 3 6 8
2012 apr 3 5 7
2012 may 3 6 8
;

proc tabulate data=have format=best6.;
class year m;
var mean median p90;
table year="Year", m=''*(mean median p90)*'mean'='';
run;
PG

View solution in original post

4 REPLIES 4
ballardw
Super User

Is your actual data presummarized or raw?

 

with raw data:

proc tabulate data=raw;
  class year month;
  var value;
  table year,
        month*value=''*(mean median P90);
run;

should work

 

DeepakSwain
Pyrite | Level 9

Hi Ballardw,

 

Summary has already been created and I am stuck at last step. If I try to put the code provided by you, what I will put in place of "value".

Thank you in advance for your kind reply. 

Regards,

 

Swain
DeepakSwain
Pyrite | Level 9

Hi there,

 

Thank you for providing me the solution using proc tabulate. This procedure was new to me. Now I got my answer which I asked you yesterday. 

 

Thank you once again.

 

Regards,

 

Swain
PGStats
Opal | Level 21

proc tabulate will do the job, with some help to get the month order correct:

 

proc format;
value m
1 = "January"
2 = "February"
3 = "March"
4 = "April"
5 = "May";
run;

data have;
input year month $ mean median p90 ;
m = whichc(month, "jan", "feb", "mar", "apr", "may");
format m m.;
drop month;
cards;
2011 jan 2 3 7
2011 feb 3 4 8
2011 mar 4 5 7
2011 apr 3 5 7
2011 may 3 6 8
2012 jan 3 5 7
2012 feb 3 6 8
2012 apr 3 5 7
2012 may 3 6 8
;

proc tabulate data=have format=best6.;
class year m;
var mean median p90;
table year="Year", m=''*(mean median p90)*'mean'='';
run;
PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 716 views
  • 2 likes
  • 3 in conversation