BookmarkSubscribeRSS Feed
luvscandy27
Quartz | Level 8

I have the following sample two datasets which I would like to merge together and add the following flags: 

 

completeyr would be flagged if regcomplete is between startdate and enddate 

completegrace would be flagged if regcomplete is between extdate and startdate

noncompliant would be flagged if the two conditions above are not met 

 

data data1;
infile datalines delimiter = ',';
input ID $ REPORT_ORDER $ ENTERDATE:mmddyy10. MONYR:monyy7. STARTDATE:mmddyy10.
ENDDATE:mmddyy10. EXTDATE:mmddyy10.;
format ENTERDATE STARTDATE ENDDATE EXTDATE mmddyy10. MONYR:monyy7.;
datalines;
100,7,04/30/2019,APR2019,04/30/2018,04/30/2019,01/31/2018
100,11,08/31/2019,AUG2019,08/31/2018,08/31/2019,05/31/2018
100,3,12/31/2018,DEC2018,12/31/2017,12/31/2018,09/30/2017
100,5,02/28/2019,FEB2019,02/28/2018,02/28/2019,11/30/2017
100,4,01/31/2019,JAN2019,01/31/2018,01/31/2019,10/31/2017
100,10,07/31/2019,JUL2019,07/31/2018,07/31/2019,04/30/2018
200,9,06/30/2019,JUN2019,06/30/2018,06/30/2019,03/31/2018
200,6,03/31/2019,MAR2019,03/31/2018,03/31/2019,12/31/2017
200,8,05/31/2019,MAY2019,05/31/2018,05/31/2019,02/28/2018
200,2,11/30/2018,NOV2018,11/30/2017,11/30/2018,08/31/2017
200,1,10/31/2018,OCT2018,10/31/2017,10/31/2018,07/31/2017
200,13,10/31/2019,OCT2019,10/31/2018,10/31/2019,07/31/2018
200,12,09/30/2019,SEP2019,09/30/2018,09/30/2019,06/30/2018
;
run;

data data2;
infile datalines delimiter = ',';
input ID $ MONYR:monyy7. REGCOMPLETE:mmddyy10.;
format MONYR monyy7. REGCOMPLETE mmddyy10.;
datalines;
100,DEC2017,12/08/2017
100,DEC2018,12/03/2018
100,OCT2019,10/24/2019
200,JUL2018,07/25/2018
;
run;

 

In certain instances an ID can be flagged for completeyr and completegrace, in which case I would like to

use the completeyr flag. Can anyone assist me with this? Below is an example of how I would like the

data to look. If the complete data were represented there would be several other Id's and the

other flag columns would have flags. 

 

IDREPORT_ORDERENTERDATEMONYRSTARTDATEENDDATEEXTDATEREGCOMPLETECOMPLETEYRCOMPLETEGRACENONCOMPLIANT
100312/31/2018Dec-1812/31/201712/31/20189/30/201712/3/20181  
100107/31/2019Jul-197/31/20187/31/20194/30/20187/25/20181  
2001310/31/2019Oct-1910/31/201810/31/20197/31/201810/24/20181  
3 REPLIES 3
PaigeMiller
Diamond | Level 26

Merge the two datasets by what criteria??

--
Paige Miller
PaigeMiller
Diamond | Level 26

Please do not post duplicate threads.

 

DO NOT REPLY FURTHER HERE

 

reply at https://communities.sas.com/t5/SAS-Programming/Merge-and-flag-variables-that-fall-between-a-specific...

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 523 views
  • 0 likes
  • 2 in conversation