how to do do some means and other calculations for daily data in SAS EG -
i have following dataset , want listed below:
data have; infile cards truncover expandtabs; input mc $ et $ date :date9. time :time. pmc $ pxmc $ site $ dia mv sf; format date date8. time hhmm.; cards; us000409 meas 12nov2016 17:26 7101 et1 1 . 2780462.00000 1 us000409 meas 12nov2016 17:33 7101 et1 1 861.26 2780462.00000 1 us000409 meas 12nov2016 17:33 7102 et1 1 861.6 2780462.00000 1 us01036 meas 12nov2016 17:26 7101 et1 2 . 522860.00000 1 us01036 meas 13nov2016 17:33 7202 et1 2 866.68 522860.00000 1 us01036 lath 13nov2016 17:33 7101 et1 2 867.36 522860.00000 1 us02044 meas 13nov2016 17:26 7202 et1 1 . 569298.00000 1 us02044 lath 13nov2016 17:33 7202 et1 1 865.32 569298.00000 1 us02044 lath 14nov2016 17:33 7202 et1 2 865.68 569298.00000 1 us318 meas 14nov2016 17:26 7101 et2 2 . 2630856.00000 1 us318 lath 14nov2016 17:33 7202 et2 3 863.26 2630856.00000 1 us318 meas 14nov2016 17:33 7202 et2 3 863.94 2630856.00000 1 us000409 meas 15nov2016 21:56 7202 et2 3 860.98 2780462.00000 1 us000409 lath 15nov2016 21:56 7203 et2 4 861.5 2780462.00000 1 us01036 meas 16nov2016 21:56 7101 et2 4 866.64 522860.00000 1 us01036 meas 16nov2016 21:56 7202 et2 4 867.34 522860.00000 1 us02044 lath 17nov2016 21:56 7203 et2 1 865.3 569298.00000 1 us02044 meas 17nov2016 21:56 7204 et2 3 865.68 569298.00000 1 us318 lath 17nov2016 21:56 7204 et2 2 863.24 2630856.00000 1 ; run;
i want compute:
1. daily mean of 'dia' each 'mc'
2. each 'pmc', step 1 above
3. each 'mc', difference between 'mv'
4. each year in 'date', how many lath there each 'mc'
i tried 1 way:
proc means data=have ; class mc; var dia; output out=want1 mean= ; run;
but looking other options , ways...
thanks.
one way calculate mean dia other variables using proc sql:
proc sql; select mc ,date ,mean(dia) meandia have group mc, date; quit;
another option:
proc means data=have; class mc date; var dia; run;
Comments
Post a Comment