BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

data have1;
format bi_date date9.;
infile datalines;
input ln_no $4.
days_past1
bi_date date9.
tot_cnt

;
return;
datalines;
1111 12 31Mar2020 1
2122 12 31Mar2020 1
1244 12 31Mar2020 1
3333 44 31Mar2020 1
2222 30 31Mar2020 1

;run;

data have2;
format bi_date date9.;
infile datalines;
input ln_no $4.
days_past2
bi_date date9.
tot_cnt

;
return;
datalines;
1111 22 30Apr2020 1
2122 32 30Apr2020 1
1244 31 30Apr2020 1
3333 30 30Apr2020 1
2222 13 30Apr2020 1

;run;

proc sort data=have1;by ln_no;run;
proc sort data=have2;by ln_no;run;

data merge_all;
merge have1 have2;
by ln_no;
run;

/***********************************/

produces the following

Category bi_date1 ln_no days_past1 tot_cnt bi_date2 days_past2
Current 31Mar2020 1111 12 1 30Apr2020 22
Curr_Past_Due 31Mar2020 1244 12 1 30Apr2020 31
Curr_Past_Due 31Mar2020 2122 12 1 30Apr2020 32
Current 31Mar2020 2222 30 1 30Apr2020 13
Past_to_Current 31Mar2020 3333 44 1 30Apr2020 30

 

I attempting to do a pivot report however proc transpose only captures the first instance of date statistics.  I am thinking a proc report may do the trick but wanted input.  Here is the desired output

Category 31-Mar-20 30-Apr-20 Pct_Chg
Current 1 1 0%
Curr_Past_Due 1 1 0%
Past_to_Current 1 0 50%
Grand Total 3 2  
4 REPLIES 4
Q1983
Lapis Lazuli | Level 10
Here is the last part with the category formula
data merge_all;
length Category $25.;
merge have1 have2;
by ln_no;
if days_past1 <=30 and days_past2 <=30 then Category='Current';
if days_past1 <=30 and days_past2 > 30 then Category='Curr_Past_Due';
if days_past1 > 30 and days_past2 <=30 then Category='Past_to_Current';

run;
Kurt_Bremser
Super User

That's highly illogical; since the category is derived from BOTH dates, there cannot be a change from one date to the other, so the report as posted makes no sense and is factually wrong.

Tom
Super User Tom
Super User

Please share the PROC REPORT code.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 451 views
  • 1 like
  • 3 in conversation