Hi Everyone,
I have data in the following format (First 2 columns). The third column 'STATUS' is my desired output. I want to generate serial numbers based on variable 'Flag' by a grouping variable 'LOC'. If flag is equal to 1, SAS should create a variable 'Status' which contains same serial number of every three rows. For example, for a group LOC =AA , the first 3 rows have value 'C1' in the table below and the next row has value 'C2'. Had it contain two more values, the next 2 rows would have a value 'C2' and so on (i.e. 'C3', 'C4'....), If Flag = 0, it should create serial number of every four rows (instead of 3).
INPUT
OUTPUT
LOC
FLAG
STATUS
AA
1
C1
AA
1
C1
AA
1
C1
AA
1
C2
AA
0
D1
AA
0
D1
AA
0
D1
AA
0
D1
AB
1
C1
AB
1
C1
AB
1
C1
AB
1
C2
AB
1
C2
AB
0
D1
AB
0
D1
AB
0
D1
AB
0
D1
The below is the sample SAS code for creating this dataset. It's just the small sample of the large data i have in the same format.
data temp;
input loc $ flag;
cards;
AA 1
AA 1
AA 1
AA 1
AA 0
AA 0
AA 0
AA 0
AA 1
AB 1
AB 1
AB 1
AB 0
AB 0
AB 0
AB 0
;
run;
... View more