Sample 24793: Validating date continuity within a BY-Group
Using BY-Group processing, determine if any clients have
had a lapse in coverage across time.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/* To check for continuous coverage, create three temporary variables */
/* which hold the earliest beginning date of coverage, the last date */
/* of coverage, and the number of days that have lapsed, if any. */
data one;
input id $ begin :yymmdd10. end :yymmdd10.;
datalines;
A 1996-01-01 1996-06-30
A 1996-02-01 1996-04-30
A 1996-03-01 1996-03-31
A 1996-08-01 1996-09-30
B 1996-01-01 1996-01-31
B 1996-02-01 1996-03-31
B 1996-04-01 1996-06-30
B 1996-07-02 1996-08-31
B 1996-09-05 1996-09-30
;
proc sort data=one ;
by id begin;
run;
/* Reassign temporary variables when the BY-Group changes. For every */
/* other observation, check to see if the current observation value */
/* of BEGIN falls within RBEGIN and REND + one. If it does, there is */
/* no break in coverage. If END is greater than REND, reassign REND. */
/* Else, if there is a break in same BY-Group, calculate lapse and */
/* reassign temporary variables for 'new coverage' dates. */
data two;
set one;
by id begin;
retain rbegin rend breakday;
drop rbegin rend;
if first.id then do;
rbegin=begin;
rend=end;
breakday=0;
end;
else do;
if rbegin<=begin <=rend +1 then do;
breakday=0;
if end > rend then rend=end;
end;
else if begin>rend+1 then do;
breakday=begin-rend-1;
rbegin=begin;
rend=end;
end;
end;
run;
proc print;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Obs id begin end breakday
1 A 13149 13330 0
2 A 13180 13269 0
3 A 13209 13239 0
4 A 13362 13422 31
5 B 13149 13179 0
6 B 13180 13239 0
7 B 13240 13330 0
8 B 13332 13392 1
9 B 13397 13422 4
Using BY-Group processing, determine if any clients have
had a lapse in coverage across time.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step Data Management ==> Manipulation and Transformation ==> BY-group processing
|
| Date Modified: | 2005-12-08 11:34:35 |
| Date Created: | 2004-09-30 14:09:14 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |