BookmarkSubscribeRSS Feed
Scottie_T
Calcite | Level 5

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)

1 REPLY 1
Shmuel
Garnet | Level 18

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;

       

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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