Pyrite | Level 9

## relative risk with CI outputting is changing direction at new visit

Hi all,

I am working on relative risk calculations for txgroup * placebo over 3 visits (week 7, 14, and 21).  This problem I am having is for some reason, the direction of the rows is switching at week 14.

So say A is row 1,  I is row 2;  Difference is (Row 1 - Row 2)  and computes normally.

This will change to I as row 1 and A as row 2 for week 14.

Resulting  Difference is (Row 1 - Row 2) is backwards.

Is there a trick to holding the row positioning  constant?  the column position is accurate so specifying  column=1 does not change anything.

``````
%macro fish1 (tx1, tx2, num, t);
proc sort data = cfrsdx; by avisitn descending avalc; run;
proc freq data = cfrsdx order=data;
by avisitn;
%if &t=0 %then %do;
where avisitn in (7 14 21) and tx in (&tx1, &tx2) & ittfl='Y' ;
%end;
%else %do;
where avisitn=(14)  and tx in (&tx1, &tx2)  & complfl = "Y";
%end;
table tx * avalc / chisq riskdiff (cl=newcombe) missing;
output out=pdata&num fisher riskdiff1;
ods output PdiffCLs=data&num;
run;
%mend fish1;``````

1 ACCEPTED SOLUTION

Accepted Solutions
Pyrite | Level 9

## Re: relative risk with CI outputting is changing direction at new visit

@ ballardw I just tried adding tx to end of my sort, and I think this did the trick!!  Sorry, i will try to explain better next time.  But thank you!!

2 REPLIES 2
Super User

## Re: relative risk with CI outputting is changing direction at new visit

Without data to see what is actually going on I suspect you are getting an interaction between the WHERE clauses and the order of TX within avisitn and  avalc. I might try adding TX to the sort as well.

If you are going to mention the role of a variable in narrative please make sure that you reference which variable. I don't see a variable "placebo" in your code and have to guess that might be "avalc" mainly because tx is kind of like txgroup.

Pyrite | Level 9

## Re: relative risk with CI outputting is changing direction at new visit

@ ballardw I just tried adding tx to end of my sort, and I think this did the trick!!  Sorry, i will try to explain better next time.  But thank you!!

Discussion stats
• 2 replies
• 1087 views
• 0 likes
• 2 in conversation