I have to following dataset that I want to summarise in SAS. Attached below is my desired data set. In excel I would make a pivot table, however I am not sure what commands I would use in sas to reach my desired data. I am new to SAS.
Thanks
| ID | Date | Amount |
| 38134805 | 1/04/2017 | 53 |
| 38257051 | 1/04/2017 | 54 |
| 38263562 | 1/04/2017 | 91 |
| 38335667 | 1/04/2017 | 76 |
| 38368668 | 1/04/2017 | 111 |
| 38373205 | 1/04/2017 | 103 |
| 38375879 | 1/04/2017 | 50 |
| 38385977 | 1/04/2017 | 85 |
| 38134805 | 1/05/2017 | 117 |
| 38257051 | 1/05/2017 | 91 |
| 38263562 | 1/05/2017 | 59 |
| 38335667 | 1/05/2017 | 107 |
| 38368668 | 1/05/2017 | 85 |
| 38373205 | 1/05/2017 | 87 |
| 38375879 | 1/05/2017 | 118 |
| 38385977 | 1/05/2017 | 62 |
| 38134805 | 1/06/2017 | 115 |
| 38257051 | 1/06/2017 | 52 |
| 38263562 | 1/06/2017 | 58 |
| 38335667 | 1/06/2017 | 61 |
| 38368668 | 1/06/2017 | 102 |
| 38373205 | 1/06/2017 | 59 |
| 38375879 | 1/06/2017 | 113 |
| 38385977 | 1/06/2017 | 51 |
And this (tested now) creates the "Total" column:
proc report data=have;
column id date,n ("Total" n=total);
define id / group;
define date / "" across format=yymmd7.;
define n / "";
define total /"";
run;
Try this:
proc report data=have;
column id n,date;
define id /group;
define date / "" across format=yymmd7.;
define n / "";
run;
Completely untested, posted from my tablet.
And this (tested now) creates the "Total" column:
proc report data=have;
column id date,n ("Total" n=total);
define id / group;
define date / "" across format=yymmd7.;
define n / "";
define total /"";
run;
data have;
infile cards truncover expandtabs;
input ID Date : ddmmyy10. Amount;
cards;
38134805 1/04/2017 53
38257051 1/04/2017 54
38263562 1/04/2017 91
38335667 1/04/2017 76
38368668 1/04/2017 111
38373205 1/04/2017 103
38375879 1/04/2017 50
38385977 1/04/2017 85
38134805 1/05/2017 117
38257051 1/05/2017 91
38263562 1/05/2017 59
38335667 1/05/2017 107
38368668 1/05/2017 85
38373205 1/05/2017 87
38375879 1/05/2017 118
38385977 1/05/2017 62
38134805 1/06/2017 115
38257051 1/06/2017 52
38263562 1/06/2017 58
38335667 1/06/2017 61
38368668 1/06/2017 102
38373205 1/06/2017 59
38375879 1/06/2017 113
38385977 1/06/2017 51
;
proc tabulate data=have;
class id date;
format date monname3.;
table id=' ' all,date=' ' all/box='ID';
keylabel all='Grand Total' n=' ';
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.