PROC TRANSPOSE 值列,同时保留日期和小时结束

PROC TRANSPOSE value column while retaining dates and Hour End

我的数据结构如下:

Meter_ID   Date         HourEnd    Value
100        12/01/2007       1       986
100        12/01/2007       2       992
100        12/01/2007       3       1002
200        12/01/2007       1       47
200        12/01/2007       2       45
200        12/01/2007       3       50
300        12/01/2007       1       32
300        12/01/2007       2       37
300        12/01/2007       3       40

并想转置信息,以便我最终得到:

Date       HourEnd        Meter100    Meter200     Meter300
12/01/2007     1             986         47           32
12/01/2007     2             992         45           37
12/01/2007     3            1002         50           40

我尝试了很多 PROC TRANSPOSE 选项和变体,但我自己也很困惑。任何帮助将不胜感激!

您需要排序。

data have;
   infile cards firstobs=2;
   input Meter_ID   Date:mmddyy. HourEnd    Value;
   format date mmddyy10.;
   cards;
Meter_ID   Date         HourEnd    Value
100        12/01/2007       1       986
100        12/01/2007       2       992
100        12/01/2007       3       1002
200        12/01/2007       1       47
200        12/01/2007       2       45
200        12/01/2007       3       50
300        12/01/2007       1       32
300        12/01/2007       2       37
300        12/01/2007       3       40
;;;;
   run;
proc print;
proc sort data=have;
   by date hourend meter_id;
   run;
proc print;
   run;
proc transpose prefix="Meter"n;
   by date hourend;
   id meter_id;
   var value;
   run;
proc print;
   run;