/* test data */
data one;
input id month :anydtdte7. invites;
format month monyy7.;
cards;
1 Jan2010 2
1 Feb2010 3
1 Mar2010 1
2 Jan2010 7
2 Feb2010 1
2 Mar2010 9
3 Jan2010 1
3 Mar2010 2
;
run;
proc format;
value idxf low--2="Below" -2<-<2="Meets" 2-high="Above";
run;
proc sql;
select one.*
, mean(invites) as meanInvites format=8.2
, putn(invites - calculated meanInvites,"idxf") as index
from one
group by month
order by id, month;
quit;
/* on lst
mean
id month invites Invites index
----------------------------------------------
1 JAN2010 2 3.33 Meets
1 FEB2010 3 2.00 Meets
1 MAR2010 1 4.00 Below
2 JAN2010 7 3.33 Above
2 FEB2010 1 2.00 Meets
2 MAR2010 9 4.00 Above
3 JAN2010 1 3.33 Below
3 MAR2010 2 4.00 Below
*/
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.
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.