BookmarkSubscribeRSS Feed
sunnyday
Calcite | Level 5

Hi Experts, I'm doing a case study for which I need some help.

 

Background - There are a bunch of people who have applied for Visa and have made multiple applications through different channels. I have to find out if a person has reapplied within 30 days of their previous application (Y/N), their reapplied channel and date. Every entry should be considered independent irrespective of multiple entries by a single person. Ex - PETE5O made first application on 5th Aug but second was not made within 30 days hence is it is not reapplied but the third was made within 30 days of second and hence it is reapplied and also the channel of reapplication would be channel of third application here (which is basically reapplication) so and so forth. There can be n number of applications made by a single person. Please advise what should I do. I have info in yellow but want to get the info in blue.

 

sunnyday_0-1676058946532.png

 

 

 

Code - 

data have;
format apply_date date9.;
input Id $ Channel $ Apply_date date9. ;
cards;
SAM1D Online 1-Oct-22
SAM1D Kiosk 9-Oct-22
PETE5O Office 5-Aug-22
PETE5O Kiosk 6-Sep-22
PETE5O Online 8-Sep-22
PETE5O Kiosk 5-Oct-22
;

 

Thanks in advance.

7 REPLIES 7
ballardw
Super User

Since you are posting the Enterprise Guide section I have to ask are you willing to accept Code or do you require a point-and-click interface approach?

 

Logic: sort data by personal identification and date of application. If your date variable is actually character the first step is to use the input function to create an actual SAS date value which happens to be a number of days.

Then use by group processing with the DIF function to get the number of days between dates

 

data have;
input Id $ Channel $ Apply_date date11. ;
format apply_date date9.;
cards;
SAM1D Online 1-Oct-22
SAM1D Kiosk 9-Oct-22
PETE5O Office 5-Aug-22
PETE5O Kiosk 6-Sep-22
PETE5O Online 8-Sep-22
PETE5O Kiosk 9-Nov-22
;

proc sort data=have;
   by id apply_date;
run;

data want;
   set have;
   by id;
   days=dif(apply_date);
   if first.id then days=0;
run;

The By statement in a data step creates automatic variables First and Last that indicate whether the observation is the first of last of a by group. So you can do things conditionally.

The DIF function takes the current value of a variable and subtracts the previous value. Since a SAS date value is number of days then you get the number of days between the dates. Set to 0 for the first observation of each ID as you don't really want the number of days from the previous person's application.

 

Since you have not provided any example that might involve multiple "reapplications" I am not sure what the output should look like and won't attack that.

sunnyday
Calcite | Level 5

Thanks for your quick response, @ballardw . I've now edited the code to make the date in SAS date format and yes, there can be chances of reapplication, which also I have included. I understand your logic of getting the difference of dates but how can I proceed further with that when it comes to flagging the reapplication channel, dates, etc. Please advice. If you can please provide a code, that would be great. Thanks.

sunnyday
Calcite | Level 5

Hi @ballardw . Even if not the whole code, but if you can even explain the logic of how can I achieve the reapplication flag, date and channel, that would be great. Thanks.

sunnyday
Calcite | Level 5

Hi Experts, I'm doing a case study for which I need some help.

 

Background - There are a bunch of people who have applied for Visa and have made multiple applications through different channels. I have to find out if a person has reapplied within 30 days of their previous application (Y/N), their reapplied channel and date. Every entry should be considered independent irrespective of multiple entries by a single person. Ex - PETE5O made first application on 5th Aug but second was not made within 30 days hence is it is not reapplied but the third was made within 30 days of second and hence it is reapplied and also the channel of reapplication would be channel of third application here (which is basically reapplication) so and so forth. There can be n number of applications made by a single person. Please advise what should I do. I have info in yellow but want to get the info in blue.

 

sunnyday_0-1676113423616.png

 

 

 

 

Code - 

data have;
format apply_date date9.;
input Id $ Channel $ Apply_date date9. ;
cards;
SAM1D Online 1-Oct-22
SAM1D Kiosk 9-Oct-22
PETE5O Office 5-Aug-22
PETE5O Kiosk 6-Sep-22
PETE5O Online 8-Sep-22
PETE5O Kiosk 5-Oct-22
;

 

Thanks in advance.

PaigeMiller
Diamond | Level 26

DUPLICATE THREAD. PLEASE DO NOT ANSWER HERE.

 

PLEASE ANSWER AT https://communities.sas.com/t5/SAS-Enterprise-Guide/Logic-for-Reapplication/m-p/858319

--
Paige Miller
sunnyday
Calcite | Level 5

Thanks @PaigeMiller  for streamlining! Please let me know if you have any solution to my problem. Thanks!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 7 replies
  • 1495 views
  • 0 likes
  • 4 in conversation