Hello,
I have a sample data set "Have". I would like to do the following steps:
1. Total Count the week gap greater than 3 based on the state; the result is shown similarly to dataset "want_count".
2. List the start week and end week number based on the state, the result is shown similarly to dataset "want_weekgap_seach".
3. List the start week and end week number based on the following rules, the result is shown similarly to dataset "want_week_gap".
a. the week gap number is the largest in the gap
b. when the week gap number is the same, list the latest week start and end.
data Have;
length State $5 Week 3;
infile datalines delimiter=',';
input State Week;
datalines;
GA,2101,
GA,2102,
GA,2104,
GA,2105,
GA,2106,
GA,2109,
GA,2110,
GA,2115,
GA,2117,
GA,2118,
GA,2120,
GA,2123,
GA,2124,
NV,2201,
NV,2202,
NV,2204,
NV,2205,
NV,2206,
NV,2209,
NV,2210,
NV,2213,
;
data want_count;
length state $5 count_total 3;
infile datalines delimiter=',';
input state Count_total;
datalines;
GA, 3,
NV, 2,
;
data want_weekgap_seach;
length State $5 Week_start 3 Week_end 3;
infile datalines delimiter=',';
input State Week_start Week_end;
datalines;
GA, 2106,2109,
GA, 2110,2115,
GA, 2120,2123,
NV, 2206,2209,
NV, 2210,2213,
;
data want_week_gap;
length State $5 Week_start 3 Week_end 3;
infile datalines delimiter=',';
input State Week_start Week_end;
datalines;
GA, 2110,2115,
NV, 2210,2213,
;
... View more