For the following data,
How can I compute Min and Max of MV in an individual month and year?
Also I don't know how to format Year and Month so that they do appear as date type YYYY and MM.
Please help.
data have;
infile cards truncover expandtabs;
input MC $ Year Month MV;
cards;
US000401 2015 3 2470237.00
US000401 2015 3 2456056.00
US000401 2015 3 2455033.00
US000401 2015 4 2514014.00
US000401 2015 4 2513327.00
US000401 2015 4 2514014.00
US000401 2015 4 2493916.00
US000401 2015 4 2492461.00
US000401 2015 4 2491547.00
US000401 2015 5 2543793.00
US000401 2015 5 2543359.00
US000401 2015 5 2518758.00
US000401 2015 5 2516837.00
US000401 2015 5 2515140.00
US000401 2015 6 2564013.00
US000401 2015 6 2563221.00
US000401 2015 6 2546570.00
US000401 2015 6 2545730.00
US000401 2015 6 2544672.00
US000401 2015 7 2585750.00
US000401 2015 7 2583685.00
US000401 2015 7 2566615.00
US000401 2015 7 2565634.00
US000401 2015 7 2564660.00
US000401 2015 8 2613465.00
US000401 2015 8 2611991.00
US000401 2015 8 2588284.00
US000401 2015 8 2587931.00
US000401 2015 8 2586864.00
US000401 2015 9 2637445.00
US000401 2015 9 2636071.00
US000401 2015 9 2615970.00
US000401 2015 9 2615112.00
US000401 2015 9 2614320.00
US000401 2015 10 2669780.00
US000401 2015 10 2668465.00
US000401 2015 10 2667387.00
US000401 2015 10 2639241.00
US000401 2015 10 2638899.00
US000401 2015 10 2638631.00
US000401 2015 11 2703315.00
US000401 2015 11 2702390.00
US000401 2015 11 2674313.00
US000401 2015 11 2673004.00
US000401 2015 11 2671232.00
US000401 2015 12 2722479.00
US000401 2015 12 2721936.00
US000401 2015 12 2705452.00
US000401 2015 12 2703832.00
;
run;
Thanks.
data have;
input MC $ Year Month MV;
yymm = mdy(month,1,year);
format yymm yymon7.;
drop year month;
cards;
US000401 2015 3 2470237.00
US000401 2015 3 2456056.00
US000401 2015 3 2455033.00
US000401 2015 4 2514014.00
US000401 2015 4 2513327.00
US000401 2015 4 2514014.00
US000401 2015 4 2493916.00
US000401 2015 4 2492461.00
US000401 2015 4 2491547.00
US000401 2015 5 2543793.00
US000401 2015 5 2543359.00
US000401 2015 5 2518758.00
US000401 2015 5 2516837.00
US000401 2015 5 2515140.00
US000401 2015 6 2564013.00
US000401 2015 6 2563221.00
US000401 2015 6 2546570.00
US000401 2015 6 2545730.00
US000401 2015 6 2544672.00
US000401 2015 7 2585750.00
US000401 2015 7 2583685.00
US000401 2015 7 2566615.00
US000401 2015 7 2565634.00
US000401 2015 7 2564660.00
US000401 2015 8 2613465.00
US000401 2015 8 2611991.00
US000401 2015 8 2588284.00
US000401 2015 8 2587931.00
US000401 2015 8 2586864.00
US000401 2015 9 2637445.00
US000401 2015 9 2636071.00
US000401 2015 9 2615970.00
US000401 2015 9 2615112.00
US000401 2015 9 2614320.00
US000401 2015 10 2669780.00
US000401 2015 10 2668465.00
US000401 2015 10 2667387.00
US000401 2015 10 2639241.00
US000401 2015 10 2638899.00
US000401 2015 10 2638631.00
US000401 2015 11 2703315.00
US000401 2015 11 2702390.00
US000401 2015 11 2674313.00
US000401 2015 11 2673004.00
US000401 2015 11 2671232.00
US000401 2015 12 2722479.00
US000401 2015 12 2721936.00
US000401 2015 12 2705452.00
US000401 2015 12 2703832.00
;;;;
run;
proc print;
run;
proc summary data=have nway;
class mc yymm;
var mv;
output out=stats(drop=_type_) min=min max=max;
run;
proc print;
run;
data have;
input MC $ Year Month MV;
yymm = mdy(month,1,year);
format yymm yymon7.;
drop year month;
cards;
US000401 2015 3 2470237.00
US000401 2015 3 2456056.00
US000401 2015 3 2455033.00
US000401 2015 4 2514014.00
US000401 2015 4 2513327.00
US000401 2015 4 2514014.00
US000401 2015 4 2493916.00
US000401 2015 4 2492461.00
US000401 2015 4 2491547.00
US000401 2015 5 2543793.00
US000401 2015 5 2543359.00
US000401 2015 5 2518758.00
US000401 2015 5 2516837.00
US000401 2015 5 2515140.00
US000401 2015 6 2564013.00
US000401 2015 6 2563221.00
US000401 2015 6 2546570.00
US000401 2015 6 2545730.00
US000401 2015 6 2544672.00
US000401 2015 7 2585750.00
US000401 2015 7 2583685.00
US000401 2015 7 2566615.00
US000401 2015 7 2565634.00
US000401 2015 7 2564660.00
US000401 2015 8 2613465.00
US000401 2015 8 2611991.00
US000401 2015 8 2588284.00
US000401 2015 8 2587931.00
US000401 2015 8 2586864.00
US000401 2015 9 2637445.00
US000401 2015 9 2636071.00
US000401 2015 9 2615970.00
US000401 2015 9 2615112.00
US000401 2015 9 2614320.00
US000401 2015 10 2669780.00
US000401 2015 10 2668465.00
US000401 2015 10 2667387.00
US000401 2015 10 2639241.00
US000401 2015 10 2638899.00
US000401 2015 10 2638631.00
US000401 2015 11 2703315.00
US000401 2015 11 2702390.00
US000401 2015 11 2674313.00
US000401 2015 11 2673004.00
US000401 2015 11 2671232.00
US000401 2015 12 2722479.00
US000401 2015 12 2721936.00
US000401 2015 12 2705452.00
US000401 2015 12 2703832.00
;;;;
run;
proc print;
run;
proc summary data=have nway;
class mc yymm;
var mv;
output out=stats(drop=_type_) min=min max=max;
run;
proc print;
run;
Kudos for a well-formulated question with nice example data. No miracle it got an immediate solution.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.