I would like to clarify few points of your post:
1) Why all TRT_DUR_QTRn are defined as $10. wheile max length is 3 characters ('x+a') ?
2) I can understand two objects comapre.
Your post: "if my current quarter is 3( qtr3) i want my array to look back into 1st and 2nd array elements." etc.
What do you ean by look back into 1st and 2nd elements ? what do yo you want to do do with them ?
3) line 55 contains "else if &tpoint._range[i-1] ='No Drug' " - where did 'No Drug' come from ?
4) As your input contains only 4 distinct values, i.e. '-' , 'a', 'x' , 'x+a' there are (4X4) 16 combinations of previous-current value
gathered into 7 group codes according to your macro:
proc format lib=work;
value group
1 = '1.New' /* ?x */
2 = '2.Win' /* ax */
3 = '3.Extension' /* ax+a */
4 = '4.Discontinue' /* x- */
5 = '5.Lose' /* x+aa */
6 = '6.Repeat' /* xx xx+a x+ax x+ax+a */
7 = '7.Not Defined' /* -- -a a- aa */
;
run;
5) finally you can simplify your code (just drop extra variables) without using macro code:
%let qtr_hbound=8;
proc format lib=work;
value group
1 = '1.New' /* ?x */
2 = '2.Win' /* ax */
3 = '3.Extension' /* ax+a */
4 = '4.Discontinue' /* x- */
5 = '5.Lose' /* x+aa */
6 = '6.Repeat' /* xx xx+a x+ax x+ax+a */
7 = '7.Not Defined' /* -- -a a- aa */
;
run;
data test1;
infile cards truncover /*missover*/;
input a_line $60.;
length trt_dur_qtr1-trt_dur_qtr&qtr_hbound $3 groupx $6;
array trtx (&qtr_hbound) $ trt_dur_qtr1-trt_dur_qtr&qtr_hbound;
array grpn group1-group&qtr_hbound;
format group1-group&qtr_hbound group15.;
do i=1 to &qtr_hbound;
trtx(i) = scan(a_line,i,' ');
if i>1 then do;
groupx = cats(trtx(i-1),trtx(i)); /* put groupx=; */
select (groupx);
when('ax') grpn(i)=2;
when ('ax+a') grpn(i)=3;
when ('x-') grpn(i)=4;
when ('x+aa') grpn(i)=5;
when ('xx','xx+a','x+ax','x+ax+a') grpn(i)=6;
otherwise grpn(i)=7;
end;
end;
else if trtx(i) = 'x'
then group1=1;
else group1=7; /* else ? */
end;
cards;
- x a - - x - x+a
x+a x+a a x - x+a x x
x x - x x+a x - x
- x+a - - x a x+a a
;
run;
... View more