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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19
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;

View solution in original post

3 REPLIES 3
data_null__
Jade | Level 19
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;
imanojkumar1
Quartz | Level 8
Just couple of modifications:

YearMonth = mdy(Month,1,Year);
format YearMonth monyy7.;

and...

proc summary data=have nway;
class MC YearMonth;
var MV;
output out=stats(drop=_type_ _FREQ_) min=MinMV max=MaxMV;
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1333 views
  • 5 likes
  • 3 in conversation