Hi. I have a dataset I'm reading in for testing purposes. I hope you can help me with this problem. It has three variables ID, FROM_DT, and CODE.
For each ID I need to be able to count the number of records for a given increment of time using the FROM_DT variable (so by Week or Month for example) from between my start date (&BGN_DT) and my end date (&END_DT). A requirement is that I need to use Proc SQL for this.
Using PROC SQL, is there a way to Group By ID and count the number of records by a particular time increment. Again, like for Week (Sunday to Saturday for Weeks 1 thru 52) and/or for Month (Jan to Dec)?
Any help here would be greatly appreciated!
%LET BGN_DT='01JAN2019'D;
%LET BGN_DT='31JAN2019'D;
DATA HAVE;
INPUT ID $ FROM_DT : DATE9. CODE $;
FORMAT FROM_DT DATE9.;
DATALINES;
F23 01JAN2019 T234
F23 30JAN2019 1234
F23 21FEB2019 1234
F23 25FEB2019 Z234
F23 23FEB2019 X234
F23 18MAR2019 1234
F23 16MAR2019 1234
F23 21MAR2019 1234
F23 31MAR2019 1234
F23 21APR2019 1234
F23 17APR2019 1234
F23 29APR2019 1234
F23 13MAY2019 1234
F23 19MAY2019 1234
F23 04MAY2019 1234
F23 01JUN2019 T234
F23 30JUN2019 1234
F23 21AUG2019 1234
F23 25AUG2019 Z234
F23 23AUG2019 X234
F23 18SEP2019 1234
F23 16SEP2019 1234
F23 21SEP2019 1234
F23 30SEP2019 1234
F23 21NOV2019 1234
F23 17NOV2019 1234
F23 29NOV2019 1234
F23 13DEC2019 1234
F23 19DEC2019 1234
F23 04DEC2019 1234
S34 01JAN2019 A344
S34 30JAN2019 A344
S34 21FEB2019 2344
S34 25FEB2019 E344
S34 23FEB2019 2344
S34 18MAR2019 2344
S34 16MAR2019 B344
S34 21MAR2019 B344
S34 31MAR2019 B344
S34 21APR2019 2344
S34 17APR2019 2344
S34 29APR2019 C344
S34 13MAY2019 D344
S34 19MAY2019 2344
S34 04MAY2019 2344
S34 01JUN2019 A344
S34 30JUN2019 A344
S34 21JUL2019 2344
S34 25JUL2019 E344
S34 23JUL2019 2344
S34 18AUG2019 2344
S34 16AUG2019 B344
S34 21AUG2019 B344
S34 30AUG2019 B344
S34 21NOV2019 2344
S34 17NOV2019 2344
S34 29NOV2019 C344
S34 13DEC2019 D344
S34 19DEC2019 2344
S34 04DEC2019 2344
;
RUN;
... View more