## Power analysis simulation for multiple testing

Hello all,

Some time ago, I wrote a code for power analysis for t-test, based on Rick's book on Simulations with SAS, and following a bug Rick published this code instead (here in the forum - the code is incomplete, I didn't want to publish it all although Rick already did):

```/********************************************************************
Effect of Sample Size on the Power of the t Test
*******************************************************************/

%let NumSamples = 1000;            /* number of samples */

data PowerSizeSim(drop=i Delta);
call streaminit(321);
Delta = 3;                       /* true difference between means */
do N =  5, 7, 8, 10, 12, 15, 20;/* sample size                   */
do SampleID = 1 to &NumSamples;
do i = 1 to N;
c = 1; x1 = rand("Normal", 0, 2);     output;
c = 2; x1 = rand("Normal", Delta, 2); output;
end;
end;
end;
run;

/* 2. Compute statistics */
%ODSOff
proc ttest data=PowerSizeSim;
by N SampleID;
class c;
var x1;
ods output ttests=TTests(where=(method="Pooled"));
run;
%ODSOn

/* 3. Construct indicator var for obs that reject H0 */
data ResultsSize;
set TTests;
RejectH0 = (Probt <= 0.05);
run;

proc freq data=ResultsSize noprint;
by N;
tables RejectH0 / out=SimPower(where=(RejectH0=1));
run;
```

Now I want to make a change, and I am not sure how to.

Instead of t-test, I want multiple tests. For example, the classic case: Clinical trial with 2 doses and a placebo, i.e., 2 comparisons (T1 vs. P and T2 vs. P). I want to use PROC MULTTEST with the Hochberg adjustment for the p values, and I define success to be when at least one dose is significantly different than the placebo (more precisely the outcome variable X is different) . For simplicity we can assume equal variances. How would you change the syntax to to that ?

I think (not sure) that the inner procedure I need is:

```ods output pValues = PV;
proc MULTTEST data = testdata hochberg pvals;
class Group;
test mean(X);
contrast 'T1 vs. P' -1 1 0;
contrast 'T2 vs. P' -1 0 1;
run;
```

It already creates a dataset with p values. So I need an assistant just in integrating it all.

## Re: Power analysis simulation for multiple testing

Well, you should include the BY statement:

BY N SampleID;

From your post, it sounds like you know how to simulate the data and your question is just "How do I use PROC MULTTEST?"

If that assumption is correct, I'll let others who are more familiar with PROC MULTTEST answer your question.  It doesn't sound like this question is connected to SAS/IML, so if you don't get a quick response, you might want to post this question to the SAS Statistcs Support Community: https://communities.sas.com/community/support-communities/sas_statistical_procedures

From The DO Loop
{"ft_lang_label":"__label__en","ft_lang_prob":0.76431274,"math_prob":0.69477034,"size":2059,"snap":"2023-40-2023-50","text_gpt3_token_len":554,"char_repetition_ratio":0.13576642,"word_repetition_ratio":0.0,"special_character_ratio":0.3462846,"punctuation_ratio":0.18867925,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9684287,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-09T19:12:03Z\",\"WARC-Record-ID\":\"<urn:uuid:c53492d9-d75e-4e57-8a2f-a2a28e0999dc>\",\"Content-Length\":\"145841\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5e7f7c5f-884d-4d57-b3d2-c63ab15a640c>\",\"WARC-Concurrent-To\":\"<urn:uuid:77ece5da-d321-4090-81ff-3657c1ce40fb>\",\"WARC-IP-Address\":\"18.67.65.30\",\"WARC-Target-URI\":\"https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Power-analysis-simulation-for-multiple-testing/td-p/217116\",\"WARC-Payload-Digest\":\"sha1:UCES3GNFL5N3UPIQ36PDFBVPJIQI4OJC\",\"WARC-Block-Digest\":\"sha1:2S3KKPXJROIS2XNE62X5RJWCSUN2JUOI\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100942.92_warc_CC-MAIN-20231209170619-20231209200619-00326.warc.gz\"}"}