DATA Step, Macro, Functions and more

How to merge multiple data for each date

Accepted Solution Solved
Reply
Contributor ZZB
Contributor
Posts: 34
Accepted Solution

How to merge multiple data for each date

I have the following dataset. I want to merge the amount of IID in the same day for each ID.

How to convert the data in the left into the data in the right? It does not matter for IID.

Thanks

  ID               Date         Volume   IID        Amount                  ID               Date            Volume   IID        Amount

1001      01/12/1980        50000    01         10000                 1001          01/12/1980        50000     ?         14200

1001      01/12/1980        50000    03          200                    1001          02/13/1980        55000     ?         14123

1001      01/12/1980        50000    02          4000        ==>     ....

1001      02/13/1980        55000    01         10009                  1009          01/12/1980        70000    ?         10200

1001      02/13/1980        55000    03          234                     1009          02/13/1980       79000     ?         10243

1001      02/13/1980        55000    02          3880

....

1009      01/12/1980        70000    01         10000

1009      01/12/1980        70000    03          200

1009      02/13/1980        79000    01         10009

1009      02/13/1980        79000    03          234

.....


Accepted Solutions
Solution
‎11-15-2014 02:19 AM
Respected Advisor
Posts: 3,893

Re: How to merge multiple data for each date

proc sql;

   create table want as

   select id, date, volume, sum(amount) as amount

   from have

   group by id, date, volume

   ;

quit;

View solution in original post


All Replies
Solution
‎11-15-2014 02:19 AM
Respected Advisor
Posts: 3,893

Re: How to merge multiple data for each date

proc sql;

   create table want as

   select id, date, volume, sum(amount) as amount

   from have

   group by id, date, volume

   ;

quit;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 136 views
  • 0 likes
  • 2 in conversation