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

Hello friend,

 

I'm trying to find median (range) of SIM per year, month, week and day from the data below. Any help is much appreciated.

 

data have;
input ID SIM Date : mmddyy12.;
format date mmddyy10.;
cards;
5648 0 1/20/2014
4489 0 2/20/2016
4564 2 6/20/2014
4587 1 8/20/2014
4578 2 1/20/2014
5645 9 12/21/2013
4564 12 11/21/2011
2587 15 10/21/2017
4254 7 3/21/2012
4545 0 3/21/2013
4587 0 1/22/2015
6968 0 7/22/2015
3254 1 5/22/2011
1215 2 11/22/2011
5456 5 10/23/2010
8999 12 1/23/2010
4555 9 2/23/2012
7894 8 7/23/2018
6968 0 2/23/2012
4455 0 5/23/2016
8789 2 1/23/2019
;
run;

 

Thanks,

Rube

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

You do this by assigning the proper format (daily, weekly, monthly) to the variable date.

 

proc summary data=have nway;
    class date; /* Date has previously been assigned a date format */
    var sim;
    output out=_daily_stats_ median=/autoname;
run;
proc summary data=have nway;
    class date;
    var sim;
    format date weeku6.; /* Weekly format */
    output out=_weekly_stats_ median=/autoname;
run;
proc summary data=have nway;
    class date;
    var sim;
    format date mmyy.; /* Monthly format */
    output out=_monthly_stats_ median=/autoname;
run;

I leave it as a homework assignment for you to figure out how to do this by year.

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

You do this by assigning the proper format (daily, weekly, monthly) to the variable date.

 

proc summary data=have nway;
    class date; /* Date has previously been assigned a date format */
    var sim;
    output out=_daily_stats_ median=/autoname;
run;
proc summary data=have nway;
    class date;
    var sim;
    format date weeku6.; /* Weekly format */
    output out=_weekly_stats_ median=/autoname;
run;
proc summary data=have nway;
    class date;
    var sim;
    format date mmyy.; /* Monthly format */
    output out=_monthly_stats_ median=/autoname;
run;

I leave it as a homework assignment for you to figure out how to do this by year.

--
Paige Miller
sandrube
Fluorite | Level 6

Thank you very much for the help!

Completed the home assignment! year4.

 

Have a wonderful weekend!

Rube

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 410 views
  • 1 like
  • 2 in conversation