DATA Step, Macro, Functions and more

Three Tables one variable needed from each

Reply
Occasional Contributor
Posts: 5

Three Tables one variable needed from each

One table was created to have all possibilities of Location_Number, Date, Hour, Quarter_Hour.

 

I have three tables with all four of these values and I want to pull the specefic revenue amount in each table that corresponds to the Location_Number, Date, Hour, and Quarter_Hour.

 

Can someone give me some sample code to get moving on joining up all Revenue from these three tables while keeping the revenue seperate from each table and revenue it pulls. (Example Pull Revenue A table when (Location_Number=Date=Hour=Quarter_Hour) then output name as Revenue A Table, repeat for Revenue B Table, Revenue C Table)

Trusted Advisor
Posts: 1,553

Re: Three Tables one variable needed from each

[ Edited ]
Posted in reply to Scottie_T

It is not clear enough what you want to get.

As much as I understand you need somthing like:

 

data RevenuA revenuB revenuC;

merge tableA(in=inA  rename=(revenue=revA))

            tableB(in=inB  rename=(revenue=revB))

            tableC(in=inC  rename=(revenue=revC))

  ;

   by Location_number date hour Quarter_Hour ;

        if inA (... and conditions ...) then do;

             revenu = revA;    

             output RevenuA;

       end;

        if inB (... and conditions ...) then do;

             revenu = revB;    

             output RevenuB;

       end;

        if inC (... and conditions ...) then do;

             revenu = revC;    

             output RevenuC;

       end;

RUN;

       

Ask a Question
Discussion stats
  • 1 reply
  • 121 views
  • 0 likes
  • 2 in conversation