BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

 

data set1;

infile datalines;

input Branch $ Sale_Date date9.   br_cnt;

return;

datalines;

Western 1jun2019 11

Eastern 1jun2019 5

Central 1jun2019 2

Wstern 1jul2019 1

Central 1aug2019 1

;run;

 

data set2;

set set1;

sale_date1=put(sale_date,MMYYD.);

drop sale_date;

run;

 

data set01;

infile datalines;

input Return_Date date9.   ret_cnt;

return;

datalines;

1jun2019 11

1jul2019 5

1jul2019 2

1aug2019 1

1aug2019 1

;run;

 

data set02;

set set01;

Return_Date1=put(Return_Date,MMYYD.);

drop Return_Date;

run;

 

data combine;

set set1 set01;

format sale_date return_date MMYYD.;

run;

 

Results

Branch

Sale_Date

br_cnt

Return_Date

ret_cnt

Western

06-2019

11

   

Eastern

06-2019

5

   

Central

06-2019

2

   

Western

07-2019

1

   

Central

08-2019

1

   
     

06-2019

11

     

07-2019

5

     

07-2019

2

     

08-2019

1

     

08-2019

1

 

 

Desired result is a proc report as follows:

Branch

06-2019

07-2019

08-2019

Row Total

Central

2

0

1

3

Eastern

5

0

0

5

Western

11

1

0

12

Total Branch

18

1

1

20

Total Return

11

7

2

20

Return Rate

163.64%

14.29%

50.00%

100.00%

 

Return rate is total branch/total return

1 REPLY 1
Cynthia_sas
SAS Super FREQ

Hi:
I'm not sure I completely understand what it is you need to do. Your data and your desired report don't make sense to me. You don't need as many datasets as you show to deal with SET1 and it's not clear to me about the extra rows you've added. Here's an example of the main report:

main_report.png

For some insight into COMPUTE blocks and adding extra rows (such as you show with your calculated percent), please refer to this paper https://support.sas.com/resources/papers/proceedings17/SAS0431-2017.pdf .

Cynthia

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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