I tried out as you suggested, but still not able to get values previous week exactly.
here goes the code and output.
data a;
input patid week day dose;
Infile cards;
cards;
1 1 1 10
1 1 3 11
1 2 1 12
1 2 3 13
1 3 1 13
1 4 1 14
1 5 1 15
1 5 3 16
1 6 1 17
1 6 3 18
;
run;
data b;
set a;
by patid;
array a(6,3);
a(week,day)=dose;
run;
proc print;run;
data a;
input patid week day dose;
Infile cards;
cards;
1 1 1 10
1 1 3 11
1 2 1 12
1 2 3 13
1 3 1 13
1 4 1 14
1 5 1 15
1 5 3 16
1 6 1 17
1 6 3 18
;
run;
data b;
set a;
by patid;
array a(6,3);
a(week,day)=dose;
run;
proc print;run;
data a;
input patid week day dose;
Infile cards;
cards;
1 1 1 10
1 1 3 11
1 2 1 12
1 2 3 13
1 3 1 13
1 4 1 14
1 5 1 15
1 5 3 16
1 6 1 17
1 6 3 18
;
run;
data b;
set a;
by patid;
array a(6,3);
a(week,day)=dose;
run;
proc print;run;
Obs
patid week day dose a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18
1 1 1 1 10 10 . . . . . . . . . . . . . . . . .
2 1 1 3 11 . . 11 . . . . . . . . . . . . . . .
3 1 2 1 12 . . . 12 . . . . . . . . . . . . . .
4 1 2 3 13 . . . . . 13 . . . . . . . . . . . .
5 1 3 1 13 . . . . . . 13 . . . . . . . . . . .
6 1 4 1 14 . . . . . . . . . 14 . . . . . . . .
7 1 5 1 15 . . . . . . . . . . . . 15 . . . . .
8 1 5 3 16 . . . . . . . . . . . . . . 16 . . .
9 1 6 1 17 . . . . . . . . . . . . . . . 17 . .
10 1 6 3 18 . . . . . . . . . . . . . . . . . 18
As this output contains missing columns of array, I think it is difficult to find which column value represents which week/day value. For example at week5 day1, still I am not able use week 4 value. please let me know if I need to any other changes to above code to resolve my issue
... View more