-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path14.SAS_BICbackwardIndOutcomeSimSce1c25.sas
883 lines (715 loc) · 40.4 KB
/
14.SAS_BICbackwardIndOutcomeSimSce1c25.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
***************************************************************************************************************************************************************************************;
*Program: 14.SAS_BICbackwardIndOutcomeSimSce1c25 ;
*Purpose: BIC backward elimination for individual outcomes for simulations of Scenario 1 with 25% censoring and training data. Obtain Union and Intersection model for each simulation ;
*Statisticians: Grisell Diaz-Ramirez and Siqi Gan ;
*Finished: 2021.01.28 ;
***************************************************************************************************************************************************************************************;
/*Check system options specified at SAS invocation*/
proc options option=work; run;
proc options option=utilloc; run;
proc options group=(memory performance); run;
libname savedata "path";
options nomlogic nomprint nomrecall nosymbolgen;
options nosource nonotes; /*nosource: suppress the listing of the SAS statements to the log, causes only source lines that contain errors to be written to the log*/
options noquotelenmax; /*supress warning: THE QUOTED STRING CURRENTLY BEING PROCESSED HAS BECOME MORE THAN 262 CHARACTERS LONG*/
ods select none; /*to create output data sets through the ODS OUTPUT statement and suppress the display of all output*/
*****************************************************PREPARE DATA FOR MACROs ********************************************************;
proc sort data=savedata.sim500trainbabicc25 out=simdata; by newid; run;
*Merge with original dataset to get the covariates;
data simdata2;
merge savedata.originaldata (drop=time_adldepdth status_adldepdth time_iadldifdth status_iadldifdth time_walkdepdth status_walkdepdth time2death death)
simdata;
by newid;
proc sort; by sim outcome newid; run;
/*5531*SIM=500->2,765,500*4outcomes=11,062,000 observations and 56+6-1=61 variables.*/
*ADL;
data simdata3;
set simdata2 (rename=(time=time_adldepdth status=status_adldepdth));
where outcome="adl";
proc sort; by sim newid; run; /*2,765,500 observations and 60 variables*/
proc delete data=simdata simdata2; run; quit;
**************************************************** DEFINE ARGUMENTS FOR MACROS: outcome, best_bic, DeleteOneVar, cstat ********************************************************;
*Note: all the macro variables for outcomes need to be in the same order, e.g. : adl iadl walk death;
%let DATA=simdata4;
%let NUMOUTCOMES=1; /*number of outcomes*/
%let ALLOUTCOME=status_adldepdth;
%let ALLTIME=time_adldepdth;
%let ALLLABEL= adl; /*labels for outcomes*/
%let NUMPRED=37; /*number of predictors without including predictors that are forced in (e.g. dAGE, SEX*/
%let NUMPREDPLUSONE=38; /*number of predictors defined in &NUMPRED (e.g.37) plus one*/
proc sql noprint; select max(sim) format 3. into :S from simdata3; quit; /*create macro variable with total number of simulated datasets*/
%put "&S";
***************************************************** BACKWARD ELIMINATION 4 INDIVIDUAL OUTCOMES: ADL **************************************************************;
/*Macro outcome, for each simulated dataset and each outcome:
1-) Calls macro BEST_BIC (calls macro DeleteOneVar)
2-) Creates one dataset with results from backward elimination
3-) Create a dataset with one line c25esponding to the best model for each individual outcome and each simulation
*/
%macro outcome;
%do i=1 %to &S; /*do this for each simulated dataset up to the last simulated dataset*/
proc sql noprint; select (&i-1)*(nobs/&S)+1 into :fobs from dictionary.tables where libname='WORK' and memname='SIMDATA3'; quit; /*create macro variable with the first id of ith simulation*/
proc sql noprint; select &i*(nobs/&S) into :lobs from dictionary.tables where libname='WORK' and memname='SIMDATA3'; quit; /*create macro variable with the last id of ith simulation*/
data simdata4;
set simdata3 (FIRSTOBS=&fobs OBS=&lobs);
run;
sasfile WORK.simdata4 load;
%PUT "&i" ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
%do j=1 %to &NUMOUTCOMES;
%let OUTCOME=%scan(&ALLOUTCOME,&j); /*extract the ith outcome, ith time, ith label*/
%let TIME=%scan(&ALLTIME,&j);
%let LABEL=%scan(&ALLLABEL,&j);
%best_bic;
sasfile WORK.BIC_&label close;
/*Create new BIC_&label dataset to merge with other outcomes*/
data BIC_&label (rename=(VARINMODEL=VARINMODEL_&label));
set BIC_&label (drop=DELELIST DELEVAR);
sim=&i;
run;
/*For each outcome and each simulation: select the best individual model*/
proc sort data=BIC_&label; by descending BIC_&label;
data BIC_&label;
set BIC_&label point=nobs nobs=nobs;
output;
stop;
run;
%end; /*j loop*/
sasfile WORK.simdata4 close;
proc delete data=simdata4; run; quit;
proc append base=BICsim_&label data=BIC_&label force; run; /*BICsim will have the information from all best individual models for each outcome and for each simulated dataset*/
proc delete data=BIC_&label; run; quit;
%PUT "&i" ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
%end; /*i loop*/
%mend outcome;
%macro best_bic;
%let BASE=%sysfunc(compbl(dAGE SEX ALCOHOL ARTHRITIS CANCER COGDLRC3G COGIMRC3G DIABETES DRIVE EDU EXERCISE EYE2G
FALL HEARAID HEARING HEARTFAILURE HYPERTENSION INCONTINENCE LALONE LUNG MSTAT OTHERARM
OTHERCHAIR OTHERCLIM3G OTHERDIME OTHERLIFT OTHERPUSH OTHERSIT OTHERSTOOP OTHERWALK PAIN CESDALL
qBMI qFAGE qMAGE SHLT SMOKING STROKE VOLUNTEER)); /*all 39 initial variables*/
%let DELE=%sysfunc(compbl(ALCOHOL ARTHRITIS CANCER COGDLRC3G COGIMRC3G DIABETES DRIVE EDU EXERCISE EYE2G
FALL HEARAID HEARING HEARTFAILURE HYPERTENSION INCONTINENCE LALONE LUNG MSTAT OTHERARM
OTHERCHAIR OTHERCLIM3G OTHERDIME OTHERLIFT OTHERPUSH OTHERSIT OTHERSTOOP OTHERWALK PAIN CESDALL
qBMI qFAGE qMAGE SHLT SMOKING STROKE VOLUNTEER)); /*all 39 variables-2(AGECAT SEX)=37*/
proc phreg data = &DATA CONCORDANCE=HARRELL rocoptions(method=RECURSIVE iauc);
class &BASE;
model &time*&outcome(0) = &BASE;
ods output FITSTATISTICS=FITS1 CONCORDANCE=concord IAUC=iauc;
run;
data _null_; set concord; call symputx ('c' ,Estimate); run;
data _null_; set iauc; call symputx ('iauc' ,Estimate); run;
data base_&label (keep=VARINMODEL DELEVAR DELELIST AIC_&label BIC_&label C_&label iauc_&label);
length VARINMODEL $ 600 DELELIST $600 DELEVAR $ 60;
set FITS1 end=last;
retain VARINMODEL DELEVAR C_&label iauc_&label AIC_&label BIC_&label;
format AIC_&label BIC_&label 10.4;
VARINMODEL="&BASE";
DELEVAR=" ";
DELELIST=" ";
C_&label=&c;
iauc_&label=&iauc;
if CRITERION='AIC' then AIC_&label=WITHCOVARIATES;
if CRITERION='SBC' then BIC_&label=WITHCOVARIATES;
if last;
run;
proc delete data=FITS1 concord iauc; run; quit;
proc append base=BIC_&label data=base_&label force; run; /*BIC is the final dataset with backward elimination steps from 39 variables to 2*/
sasfile WORK.BIC_&label load;
proc delete data=base_&label; run; quit;
%do k=1 %to &NUMPRED;
%DeleteOneVar;
data _null_;
set CTABLE_&label (keep=VARINMODEL DELELIST);
call symputx ('BASE' ,VARINMODEL);
call symputx ('DELE' ,DELELIST);
run;
proc append base=BIC_&label data=CTABLE_&label force; run;
proc delete data=CTABLE_&label; run; quit;
%end;
%mend best_bic;
%macro DeleteOneVar;
%do l=1 %to %eval(&NUMPREDPLUSONE-&k);
%let DELEVAR=%scan(&DELE,&l); /*select the lth word to delete. &DELE is defined in 'best_bic' macro*/
%let VARNAME=%sysfunc(compbl(%sysfunc(tranwrd(&BASE,&DELEVAR,%str( ))))); /*select the final set of variables to run model by replacing the deleted variable with blank*/
proc phreg data = &DATA CONCORDANCE=HARRELL rocoptions(method=RECURSIVE iauc);
class &VARNAME;
model &time*&outcome(0) = &VARNAME;
ods output FITSTATISTICS=FITS1 CONCORDANCE=concord IAUC=iauc;
run;
data _null_; set concord; call symputx ('c' ,Estimate); run;
data _null_; set iauc; call symputx ('iauc' ,Estimate); run;
data FITS2 (keep=VARINMODEL DELEVAR DELELIST AIC_&label BIC_&label C_&label iauc_&label);
length VARINMODEL $ 600 DELELIST $600 DELEVAR $ 60;
set FITS1 end=last;
retain VARINMODEL DELEVAR C_&label iauc_&label AIC_&label BIC_&label;
format AIC_&label BIC_&label 10.4;
VARINMODEL="&VARNAME"; /*variables in the model*/
DELEVAR="&DELEVAR"; /*deleted variable*/
DELELIST=compbl(tranwrd("&DELE","&DELEVAR",' ')); /*'DELELIST' contain the list of variables that we need to start with in subsequent run*/
C_&label=&c;
iauc_&label=&iauc;
if CRITERION='AIC' then AIC_&label=WITHCOVARIATES;
if CRITERION='SBC' then BIC_&label=WITHCOVARIATES;
if last;
run;
%if &l=1 %then %do; /*in the 1st line of CTABLE_&label create CTABLE_&label dataset*/
proc append base=CTABLE_&label data=FITS2 force; run;
sasfile WORK.CTABLE_&label load;
%end;
%else %do; /*for the rest of lines of CTABLE_&label: keep updating CTABLE_&label dataset in memory*/
proc append base=CTABLE_&label data=FITS2 force; run;
%end;
proc delete data=FITS1 FITS2 concord iauc; run; quit;
/*proc delete data=FITS1 FITS2 CensUncens DF concord iauc; run; quit;*/
%end;
sasfile WORK.CTABLE_&label close;
proc sort data=CTABLE_&label; by descending BIC_&label; run;
data CTABLE_&label;
set CTABLE_&label point=nobs nobs=nobs;
output;
stop;
run; /*choose the last observation with minimum BIC*/
%mend DeleteOneVar;
%PUT ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
%outcome;
%PUT ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
*Create permanent dataset;
%let LABEL= adl; /*labels for outcomes*/
data savedata.BICsim_c25_&label; set BICsim_&label; proc sort; by sim; run;
proc delete data=BICsim_&label; run; quit;
***************************************************** END BACKWARD ELIMINATION 4 INDIVIDUAL OUTCOMES: ADL ******************************************************************;
*****************************************************PREPARE DATA FOR MACROs ********************************************************;
proc sort data=savedata.sim500trainbabicc25 out=simdata; by newid; run;
*Merge with original dataset to get the covariates;
data simdata2;
merge savedata.originaldata (drop=time_adldepdth status_adldepdth time_iadldifdth status_iadldifdth time_walkdepdth status_walkdepdth time2death death)
simdata;
by newid;
proc sort; by sim outcome newid; run;
/*5531*SIM=500->2,765,500*4outcomes=11,062,000 observations and 56+6-1=61 variables.*/
*IADL;
data simdata3;
set simdata2 (rename=(time=time_iadldifdth status=status_iadldifdth));
where outcome="iadl";
proc sort; by sim newid; run; /*2,765,500 observations and 60 variables*/
proc delete data=simdata simdata2; run; quit;
**************************************************** DEFINE ARGUMENTS FOR MACROS: outcome, best_bic, DeleteOneVar, cstat ********************************************************;
*Note: all the macro variables for outcomes need to be in the same order, e.g. : adl iadl walk death;
%let DATA=simdata4;
%let NUMOUTCOMES=1; /*number of outcomes*/
%let ALLOUTCOME=status_iadldifdth;
%let ALLTIME=time_iadldifdth;
%let ALLLABEL= iadl; /*labels for outcomes*/
%let NUMPRED=37; /*number of predictors without including predictors that are forced in (e.g. dAGE, SEX*/
%let NUMPREDPLUSONE=38; /*number of predictors defined in &NUMPRED (e.g.37) plus one*/
proc sql noprint; select max(sim) format 3. into :S from simdata3; quit; /*create macro variable with total number of simulated datasets*/
%put "&S";
***************************************************** BACKWARD ELIMINATION 4 INDIVIDUAL OUTCOMES: IADL **************************************************************;
/*Macro outcome, for each simulated dataset and each outcome:
1-) Calls macro BEST_BIC (calls macro DeleteOneVar)
2-) Creates one dataset with results from backward elimination
3-) Create a dataset with one line c25esponding to the best model for each individual outcome and each simulation
*/
%macro outcome;
%do i=1 %to &S; /*do this for each simulated dataset up to the last simulated dataset*/
proc sql noprint; select (&i-1)*(nobs/&S)+1 into :fobs from dictionary.tables where libname='WORK' and memname='SIMDATA3'; quit; /*create macro variable with the first id of ith simulation*/
proc sql noprint; select &i*(nobs/&S) into :lobs from dictionary.tables where libname='WORK' and memname='SIMDATA3'; quit; /*create macro variable with the last id of ith simulation*/
data simdata4;
set simdata3 (FIRSTOBS=&fobs OBS=&lobs);
run;
sasfile WORK.simdata4 load;
%PUT "&i" ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
%do j=1 %to &NUMOUTCOMES;
%let OUTCOME=%scan(&ALLOUTCOME,&j); /*extract the ith outcome, ith time, ith label*/
%let TIME=%scan(&ALLTIME,&j);
%let LABEL=%scan(&ALLLABEL,&j);
%best_bic;
sasfile WORK.BIC_&label close;
/*Create new BIC_&label dataset to merge with other outcomes*/
data BIC_&label (rename=(VARINMODEL=VARINMODEL_&label));
set BIC_&label (drop=DELELIST DELEVAR);
sim=&i;
run;
/*For each outcome and each simulation: select the best individual model*/
proc sort data=BIC_&label; by descending BIC_&label;
data BIC_&label;
set BIC_&label point=nobs nobs=nobs;
output;
stop;
run;
%end; /*j loop*/
sasfile WORK.simdata4 close;
proc delete data=simdata4; run; quit;
proc append base=BICsim_&label data=BIC_&label force; run; /*BICsim will have the information from all best individual models for each outcome and for each simulated dataset*/
proc delete data=BIC_&label; run; quit;
%PUT "&i" ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
%end; /*i loop*/
%mend outcome;
%macro best_bic;
%let BASE=%sysfunc(compbl(dAGE SEX ALCOHOL ARTHRITIS CANCER COGDLRC3G COGIMRC3G DIABETES DRIVE EDU EXERCISE EYE2G
FALL HEARAID HEARING HEARTFAILURE HYPERTENSION INCONTINENCE LALONE LUNG MSTAT OTHERARM
OTHERCHAIR OTHERCLIM3G OTHERDIME OTHERLIFT OTHERPUSH OTHERSIT OTHERSTOOP OTHERWALK PAIN CESDALL
qBMI qFAGE qMAGE SHLT SMOKING STROKE VOLUNTEER)); /*all 39 initial variables*/
%let DELE=%sysfunc(compbl(ALCOHOL ARTHRITIS CANCER COGDLRC3G COGIMRC3G DIABETES DRIVE EDU EXERCISE EYE2G
FALL HEARAID HEARING HEARTFAILURE HYPERTENSION INCONTINENCE LALONE LUNG MSTAT OTHERARM
OTHERCHAIR OTHERCLIM3G OTHERDIME OTHERLIFT OTHERPUSH OTHERSIT OTHERSTOOP OTHERWALK PAIN CESDALL
qBMI qFAGE qMAGE SHLT SMOKING STROKE VOLUNTEER)); /*all 39 variables-2(AGECAT SEX)=37*/
proc phreg data = &DATA CONCORDANCE=HARRELL rocoptions(method=RECURSIVE iauc);
class &BASE;
model &time*&outcome(0) = &BASE;
ods output FITSTATISTICS=FITS1 CONCORDANCE=concord IAUC=iauc;
run;
data _null_; set concord; call symputx ('c' ,Estimate); run;
data _null_; set iauc; call symputx ('iauc' ,Estimate); run;
data base_&label (keep=VARINMODEL DELEVAR DELELIST AIC_&label BIC_&label C_&label iauc_&label);
length VARINMODEL $ 600 DELELIST $600 DELEVAR $ 60;
set FITS1 end=last;
retain VARINMODEL DELEVAR C_&label iauc_&label AIC_&label BIC_&label;
format AIC_&label BIC_&label 10.4;
VARINMODEL="&BASE";
DELEVAR=" ";
DELELIST=" ";
C_&label=&c;
iauc_&label=&iauc;
if CRITERION='AIC' then AIC_&label=WITHCOVARIATES;
if CRITERION='SBC' then BIC_&label=WITHCOVARIATES;
if last;
run;
proc delete data=FITS1 concord iauc; run; quit;
proc append base=BIC_&label data=base_&label force; run; /*BIC is the final dataset with backward elimination steps from 39 variables to 2*/
sasfile WORK.BIC_&label load;
proc delete data=base_&label; run; quit;
%do k=1 %to &NUMPRED;
%DeleteOneVar;
data _null_;
set CTABLE_&label (keep=VARINMODEL DELELIST);
call symputx ('BASE' ,VARINMODEL);
call symputx ('DELE' ,DELELIST);
run;
proc append base=BIC_&label data=CTABLE_&label force; run;
proc delete data=CTABLE_&label; run; quit;
%end;
%mend best_bic;
%macro DeleteOneVar;
%do l=1 %to %eval(&NUMPREDPLUSONE-&k);
%let DELEVAR=%scan(&DELE,&l); /*select the lth word to delete. &DELE is defined in 'best_bic' macro*/
%let VARNAME=%sysfunc(compbl(%sysfunc(tranwrd(&BASE,&DELEVAR,%str( ))))); /*select the final set of variables to run model by replacing the deleted variable with blank*/
proc phreg data = &DATA CONCORDANCE=HARRELL rocoptions(method=RECURSIVE iauc);
class &VARNAME;
model &time*&outcome(0) = &VARNAME;
ods output FITSTATISTICS=FITS1 CONCORDANCE=concord IAUC=iauc;
run;
data _null_; set concord; call symputx ('c' ,Estimate); run;
data _null_; set iauc; call symputx ('iauc' ,Estimate); run;
data FITS2 (keep=VARINMODEL DELEVAR DELELIST AIC_&label BIC_&label C_&label iauc_&label);
length VARINMODEL $ 600 DELELIST $600 DELEVAR $ 60;
set FITS1 end=last;
retain VARINMODEL DELEVAR C_&label iauc_&label AIC_&label BIC_&label;
format AIC_&label BIC_&label 10.4;
VARINMODEL="&VARNAME"; /*variables in the model*/
DELEVAR="&DELEVAR"; /*deleted variable*/
DELELIST=compbl(tranwrd("&DELE","&DELEVAR",' ')); /*'DELELIST' contain the list of variables that we need to start with in subsequent run.*/
C_&label=&c;
iauc_&label=&iauc;
if CRITERION='AIC' then AIC_&label=WITHCOVARIATES;
if CRITERION='SBC' then BIC_&label=WITHCOVARIATES;
if last;
run;
%if &l=1 %then %do; /*in the 1st line of CTABLE_&label create CTABLE_&label dataset*/
proc append base=CTABLE_&label data=FITS2 force; run;
sasfile WORK.CTABLE_&label load;
%end;
%else %do; /*for the rest of lines of CTABLE_&label: keep updating CTABLE_&label dataset in memory*/
proc append base=CTABLE_&label data=FITS2 force; run;
%end;
proc delete data=FITS1 FITS2 concord iauc; run; quit;
/*proc delete data=FITS1 FITS2 CensUncens DF concord iauc; run; quit;*/
%end;
sasfile WORK.CTABLE_&label close;
proc sort data=CTABLE_&label; by descending BIC_&label; run;
data CTABLE_&label;
set CTABLE_&label point=nobs nobs=nobs;
output;
stop;
run; /*choose the last observation with minimum BIC*/
%mend DeleteOneVar;
%PUT ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
%outcome;
%PUT ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
*Create permanent dataset;
%let LABEL= iadl; /*labels for outcomes*/
data savedata.BICsim_c25_&label; set BICsim_&label; proc sort; by sim; run;
proc delete data=BICsim_&label; run; quit;
***************************************************** END BACKWARD ELIMINATION 4 INDIVIDUAL OUTCOMES: IADL ******************************************************************;
*****************************************************PREPARE DATA FOR MACROs ********************************************************;
proc sort data=savedata.sim500trainbabicc25 out=simdata; by newid; run;
*Merge with original dataset to get the covariates;
data simdata2;
merge savedata.originaldata (drop=time_adldepdth status_adldepdth time_iadldifdth status_iadldifdth time_walkdepdth status_walkdepdth time2death death)
simdata;
by newid;
proc sort; by sim outcome newid; run;
/*5531*SIM=500->2,765,500*4outcomes=11,062,000 observations and 56+6-1=61 variables.*/
*Walk;
data simdata3;
set simdata2 (rename=(time=time_walkdepdth status=status_walkdepdth));
where outcome="walk";
proc sort; by sim newid; run; /*2,765,500 observations and 60 variables*/
proc delete data=simdata simdata2; run; quit;
**************************************************** DEFINE ARGUMENTS FOR MACROS: outcome, best_bic, DeleteOneVar, cstat ********************************************************;
*Note: all the macro variables for outcomes need to be in the same order, e.g. : adl iadl walk death;
%let DATA=simdata4;
%let NUMOUTCOMES=1; /*number of outcomes*/
%let ALLOUTCOME=status_walkdepdth;
%let ALLTIME=time_walkdepdth;
%let ALLLABEL= walk; /*labels for outcomes*/
%let NUMPRED=37; /*number of predictors without including predictors that are forced in (e.g. dAGE, SEX*/
%let NUMPREDPLUSONE=38; /*number of predictors defined in &NUMPRED (e.g.37) plus one*/
proc sql noprint; select max(sim) format 3. into :S from simdata3; quit; /*create macro variable with total number of simulated datasets*/
%put "&S";
***************************************************** BACKWARD ELIMINATION 4 INDIVIDUAL OUTCOMES: WALK **************************************************************;
/*Macro outcome, for each simulated dataset and each outcome:
1-) Calls macro BEST_BIC (calls macro DeleteOneVar)
2-) Creates one dataset with results from backward elimination
3-) Create a dataset with one line c25esponding to the best model for each individual outcome and each simulation
*/
%macro outcome;
%do i=1 %to &S; /*do this for each simulated dataset up to the last simulated dataset*/
proc sql noprint; select (&i-1)*(nobs/&S)+1 into :fobs from dictionary.tables where libname='WORK' and memname='SIMDATA3'; quit; /*create macro variable with the first id of ith simulation*/
proc sql noprint; select &i*(nobs/&S) into :lobs from dictionary.tables where libname='WORK' and memname='SIMDATA3'; quit; /*create macro variable with the last id of ith simulation*/
data simdata4;
set simdata3 (FIRSTOBS=&fobs OBS=&lobs);
run;
sasfile WORK.simdata4 load;
%PUT "&i" ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
%do j=1 %to &NUMOUTCOMES;
%let OUTCOME=%scan(&ALLOUTCOME,&j); /*extract the ith outcome, ith time, ith label*/
%let TIME=%scan(&ALLTIME,&j);
%let LABEL=%scan(&ALLLABEL,&j);
%best_bic;
sasfile WORK.BIC_&label close;
/*Create new BIC_&label dataset to merge with other outcomes*/
data BIC_&label (rename=(VARINMODEL=VARINMODEL_&label );
set BIC_&label (drop=DELELIST DELEVAR);
sim=&i;
run;
/*For each outcome and each simulation: select the best individual model*/
proc sort data=BIC_&label; by descending BIC_&label;
data BIC_&label;
set BIC_&label point=nobs nobs=nobs;
output;
stop;
run;
%end; /*j loop*/
sasfile WORK.simdata4 close;
proc delete data=simdata4; run; quit;
proc append base=BICsim_&label data=BIC_&label force; run; /*BICsim will have the information from all best individual models for each outcome and for each simulated dataset*/
proc delete data=BIC_&label; run; quit;
%PUT "&i" ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
%end; /*i loop*/
%mend outcome;
%macro best_bic;
%let BASE=%sysfunc(compbl(dAGE SEX ALCOHOL ARTHRITIS CANCER COGDLRC3G COGIMRC3G DIABETES DRIVE EDU EXERCISE EYE2G
FALL HEARAID HEARING HEARTFAILURE HYPERTENSION INCONTINENCE LALONE LUNG MSTAT OTHERARM
OTHERCHAIR OTHERCLIM3G OTHERDIME OTHERLIFT OTHERPUSH OTHERSIT OTHERSTOOP OTHERWALK PAIN CESDALL
qBMI qFAGE qMAGE SHLT SMOKING STROKE VOLUNTEER)); /*all 39 initial variables*/
%let DELE=%sysfunc(compbl(ALCOHOL ARTHRITIS CANCER COGDLRC3G COGIMRC3G DIABETES DRIVE EDU EXERCISE EYE2G
FALL HEARAID HEARING HEARTFAILURE HYPERTENSION INCONTINENCE LALONE LUNG MSTAT OTHERARM
OTHERCHAIR OTHERCLIM3G OTHERDIME OTHERLIFT OTHERPUSH OTHERSIT OTHERSTOOP OTHERWALK PAIN CESDALL
qBMI qFAGE qMAGE SHLT SMOKING STROKE VOLUNTEER)); /*all 39 variables-2(AGECAT SEX)=37*/
proc phreg data = &DATA CONCORDANCE=HARRELL rocoptions(method=RECURSIVE iauc);
class &BASE;
model &time*&outcome(0) = &BASE;
ods output FITSTATISTICS=FITS1 CONCORDANCE=concord IAUC=iauc;
run;
data _null_; set concord; call symputx ('c' ,Estimate); run;
data _null_; set iauc; call symputx ('iauc' ,Estimate); run;
data base_&label (keep=VARINMODEL DELEVAR DELELIST AIC_&label BIC_&label C_&label iauc_&label);
length VARINMODEL $ 600 DELELIST $600 DELEVAR $ 60;
set FITS1 end=last;
retain VARINMODEL DELEVAR C_&label iauc_&label AIC_&label BIC_&label;
format AIC_&label BIC_&label 10.4;
VARINMODEL="&BASE";
DELEVAR=" ";
DELELIST=" ";
C_&label=&c;
iauc_&label=&iauc;
if CRITERION='AIC' then AIC_&label=WITHCOVARIATES;
if CRITERION='SBC' then BIC_&label=WITHCOVARIATES;
if last;
run;
proc delete data=FITS1 concord iauc; run; quit;
proc append base=BIC_&label data=base_&label force; run; /*BIC is the final dataset with backward elimination steps from 39 variables to 2*/
sasfile WORK.BIC_&label load;
proc delete data=base_&label; run; quit;
%do k=1 %to &NUMPRED;
%DeleteOneVar;
data _null_;
set CTABLE_&label (keep=VARINMODEL DELELIST );
call symputx ('BASE' ,VARINMODEL);
call symputx ('DELE' ,DELELIST);
run;
proc append base=BIC_&label data=CTABLE_&label force; run;
proc delete data=CTABLE_&label; run; quit;
%end;
%mend best_bic;
%macro DeleteOneVar;
%do l=1 %to %eval(&NUMPREDPLUSONE-&k);
%let DELEVAR=%scan(&DELE,&l); /*select the lth word to delete. &DELE is defined in 'best_bic' macro*/
%let VARNAME=%sysfunc(compbl(%sysfunc(tranwrd(&BASE,&DELEVAR,%str( ))))); /*select the final set of variables to run model by replacing the deleted variable with blank*/
proc phreg data = &DATA CONCORDANCE=HARRELL rocoptions(method=RECURSIVE iauc);
class &VARNAME;
model &time*&outcome(0) = &VARNAME;
ods output FITSTATISTICS=FITS1 CONCORDANCE=concord IAUC=iauc;
run;
data _null_; set concord; call symputx ('c' ,Estimate); run;
data _null_; set iauc; call symputx ('iauc' ,Estimate); run;
data FITS2 (keep=VARINMODEL DELEVAR DELELIST AIC_&label BIC_&label C_&label iauc_&label);
length VARINMODEL $ 600 DELELIST $600 DELEVAR $ 60;
set FITS1 end=last;
retain VARINMODEL DELEVAR C_&label iauc_&label AIC_&label BIC_&label;
format AIC_&label BIC_&label 10.4;
VARINMODEL="&VARNAME"; /*variables in the model*/
DELEVAR="&DELEVAR"; /*deleted variable*/
DELELIST=compbl(tranwrd("&DELE","&DELEVAR",' ')); /*'DELELIST' contain the list of variables that we need to start with in subsequent run.*/
C_&label=&c;
iauc_&label=&iauc;
if CRITERION='AIC' then AIC_&label=WITHCOVARIATES;
if CRITERION='SBC' then BIC_&label=WITHCOVARIATES;
if last;
run;
%if &l=1 %then %do; /*in the 1st line of CTABLE_&label create CTABLE_&label dataset*/
proc append base=CTABLE_&label data=FITS2 force; run;
sasfile WORK.CTABLE_&label load;
%end;
%else %do; /*for the rest of lines of CTABLE_&label: keep updating CTABLE_&label dataset in memory*/
proc append base=CTABLE_&label data=FITS2 force; run;
%end;
proc delete data=FITS1 FITS2 concord iauc; run; quit;
/*proc delete data=FITS1 FITS2 CensUncens DF concord iauc; run; quit;*/
%end;
sasfile WORK.CTABLE_&label close;
proc sort data=CTABLE_&label; by descending BIC_&label; run;
data CTABLE_&label;
set CTABLE_&label point=nobs nobs=nobs;
output;
stop;
run; /*choose the last observation with minimum BIC*/
%mend DeleteOneVar;
%PUT ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
%outcome;
%PUT ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
*Create permanent dataset;
%let LABEL= walk; /*labels for outcomes*/
data savedata.BICsim_c25_&label; set BICsim_&label; proc sort; by sim; run;
proc delete data=BICsim_&label; run; quit;
***************************************************** END BACKWARD ELIMINATION 4 INDIVIDUAL OUTCOMES: WALK ******************************************************************;
*****************************************************PREPARE DATA FOR MACROs ********************************************************;
proc sort data=savedata.sim500trainbabicc25 out=simdata; by newid; run;
*Merge with original dataset to get the covariates;
data simdata2;
merge savedata.originaldata (drop=time_adldepdth status_adldepdth time_iadldifdth status_iadldifdth time_walkdepdth status_walkdepdth time2death death)
simdata;
by newid;
proc sort; by sim outcome newid; run;
/*5531*SIM=500->2,765,500*4outcomes=11,062,000 observations and 56+6-1=61 variables.*/
*Death;
data simdata3;
set simdata2 (rename=(time=time2death status=death));
where outcome="death";
proc sort; by sim newid; run; /*2,765,500 observations and 60 variables*/
proc delete data=simdata simdata2; run; quit;
**************************************************** DEFINE ARGUMENTS FOR MACROS: outcome, best_bic, DeleteOneVar, cstat ********************************************************;
*Note: all the macro variables for outcomes need to be in the same order, e.g. : adl iadl walk death;
%let DATA=simdata4;
%let NUMOUTCOMES=1; /*number of outcomes*/
%let ALLOUTCOME=death;
%let ALLTIME=time2death;
%let ALLLABEL= death; /*labels for outcomes*/
%let NUMPRED=37; /*number of predictors without including predictors that are forced in (e.g. dAGE, SEX*/
%let NUMPREDPLUSONE=38; /*number of predictors defined in &NUMPRED (e.g.37) plus one*/
proc sql noprint; select max(sim) format 3. into :S from simdata3; quit; /*create macro variable with total number of simulated datasets*/
%put "&S";
***************************************************** BACKWARD ELIMINATION 4 INDIVIDUAL OUTCOMES: DEATH **************************************************************;
/*Macro outcome, for each simulated dataset and each outcome:
1-) Calls macro BEST_BIC (calls macro DeleteOneVar)
2-) Creates one dataset with results from backward elimination
3-) Create a dataset with one line c25esponding to the best model for each individual outcome and each simulation
*/
%macro outcome;
%do i=1 %to &S; /*do this for each simulated dataset up to the last simulated dataset*/
proc sql noprint; select (&i-1)*(nobs/&S)+1 into :fobs from dictionary.tables where libname='WORK' and memname='SIMDATA3'; quit; /*create macro variable with the first id of ith simulation*/
proc sql noprint; select &i*(nobs/&S) into :lobs from dictionary.tables where libname='WORK' and memname='SIMDATA3'; quit; /*create macro variable with the last id of ith simulation*/
data simdata4;
set simdata3 (FIRSTOBS=&fobs OBS=&lobs);
run;
sasfile WORK.simdata4 load;
%PUT "&i" ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
%do j=1 %to &NUMOUTCOMES;
%let OUTCOME=%scan(&ALLOUTCOME,&j); /*extract the ith outcome, ith time, ith label*/
%let TIME=%scan(&ALLTIME,&j);
%let LABEL=%scan(&ALLLABEL,&j);
%best_bic;
sasfile WORK.BIC_&label close;
/*Create new BIC_&label dataset to merge with other outcomes*/
data BIC_&label (rename=(VARINMODEL=VARINMODEL_&label ));
set BIC_&label (drop=DELELIST DELEVAR);
sim=&i;
run;
/*For each outcome and each simulation: select the best individual model*/
proc sort data=BIC_&label; by descending BIC_&label;
data BIC_&label;
set BIC_&label point=nobs nobs=nobs;
output;
stop;
run;
%end; /*j loop*/
sasfile WORK.simdata4 close;
proc delete data=simdata4; run; quit;
proc append base=BICsim_&label data=BIC_&label force; run; /*BICsim will have the information from all best individual models for each outcome and for each simulated dataset*/
proc delete data=BIC_&label; run; quit;
%PUT "&i" ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
%end; /*i loop*/
%mend outcome;
%macro best_bic;
%let BASE=%sysfunc(compbl(dAGE SEX ALCOHOL ARTHRITIS CANCER COGDLRC3G COGIMRC3G DIABETES DRIVE EDU EXERCISE EYE2G
FALL HEARAID HEARING HEARTFAILURE HYPERTENSION INCONTINENCE LALONE LUNG MSTAT OTHERARM
OTHERCHAIR OTHERCLIM3G OTHERDIME OTHERLIFT OTHERPUSH OTHERSIT OTHERSTOOP OTHERWALK PAIN CESDALL
qBMI qFAGE qMAGE SHLT SMOKING STROKE VOLUNTEER)); /*all 39 initial variables*/
%let DELE=%sysfunc(compbl(ALCOHOL ARTHRITIS CANCER COGDLRC3G COGIMRC3G DIABETES DRIVE EDU EXERCISE EYE2G
FALL HEARAID HEARING HEARTFAILURE HYPERTENSION INCONTINENCE LALONE LUNG MSTAT OTHERARM
OTHERCHAIR OTHERCLIM3G OTHERDIME OTHERLIFT OTHERPUSH OTHERSIT OTHERSTOOP OTHERWALK PAIN CESDALL
qBMI qFAGE qMAGE SHLT SMOKING STROKE VOLUNTEER)); /*all 39 variables-2(AGECAT SEX)=37*/
proc phreg data = &DATA CONCORDANCE=HARRELL rocoptions(method=RECURSIVE iauc);
class &BASE;
model &time*&outcome(0) = &BASE;
ods output FITSTATISTICS=FITS1 CONCORDANCE=concord IAUC=iauc;
run;
data _null_; set concord; call symputx ('c' ,Estimate); run;
data _null_; set iauc; call symputx ('iauc' ,Estimate); run;
data base_&label (keep=VARINMODEL DELEVAR DELELIST AIC_&label BIC_&label C_&label iauc_&label);
length VARINMODEL $ 600 DELELIST $600 DELEVAR $ 60;
set FITS1 end=last;
retain VARINMODEL DELEVAR C_&label iauc_&label AIC_&label BIC_&label;
format AIC_&label BIC_&label 10.4;
VARINMODEL="&BASE";
DELEVAR=" ";
DELELIST=" ";
C_&label=&c;
iauc_&label=&iauc;
if CRITERION='AIC' then AIC_&label=WITHCOVARIATES;
if CRITERION='SBC' then BIC_&label=WITHCOVARIATES;
if last;
run;
proc delete data=FITS1 concord iauc; run; quit;
proc append base=BIC_&label data=base_&label force; run; /*BIC is the final dataset with backward elimination steps from 39 variables to 2*/
sasfile WORK.BIC_&label load;
proc delete data=base_&label; run; quit;
%do k=1 %to &NUMPRED;
%DeleteOneVar;
data _null_;
set CTABLE_&label (keep=VARINMODEL DELELIST );
call symputx ('BASE' ,VARINMODEL);
call symputx ('DELE' ,DELELIST);
run;
proc append base=BIC_&label data=CTABLE_&label force; run;
proc delete data=CTABLE_&label; run; quit;
%end;
%mend best_bic;
%macro DeleteOneVar;
%do l=1 %to %eval(&NUMPREDPLUSONE-&k);
%let DELEVAR=%scan(&DELE,&l); /*select the lth word to delete. &DELE is defined in 'best_bic' macro*/
%let VARNAME=%sysfunc(compbl(%sysfunc(tranwrd(&BASE,&DELEVAR,%str( ))))); /*select the final set of variables to run model by replacing the deleted variable with blank*/
proc phreg data = &DATA CONCORDANCE=HARRELL rocoptions(method=RECURSIVE iauc);
class &VARNAME;
model &time*&outcome(0) = &VARNAME;
ods output FITSTATISTICS=FITS1 CONCORDANCE=concord IAUC=iauc;
run;
data _null_; set concord; call symputx ('c' ,Estimate); run;
data _null_; set iauc; call symputx ('iauc' ,Estimate); run;
data FITS2 (keep=VARINMODEL DELEVAR DELELIST AIC_&label BIC_&label C_&label iauc_&label);
length VARINMODEL $ 600 DELELIST $600 DELEVAR $ 60;
set FITS1 end=last;
retain VARINMODEL DELEVAR C_&label iauc_&label AIC_&label BIC_&label;
format AIC_&label BIC_&label 10.4;
VARINMODEL="&VARNAME"; /*variables in the model*/
DELEVAR="&DELEVAR"; /*deleted variable*/
DELELIST=compbl(tranwrd("&DELE","&DELEVAR",' ')); /*'DELELIST' contain the list of variables that we need to start with in subsequent run.*/
C_&label=&c;
iauc_&label=&iauc;
if CRITERION='AIC' then AIC_&label=WITHCOVARIATES;
if CRITERION='SBC' then BIC_&label=WITHCOVARIATES;
if last;
run;
%if &l=1 %then %do; /*in the 1st line of CTABLE_&label create CTABLE_&label dataset*/
proc append base=CTABLE_&label data=FITS2 force; run;
sasfile WORK.CTABLE_&label load;
%end;
%else %do; /*for the rest of lines of CTABLE_&label: keep updating CTABLE_&label dataset in memory*/
proc append base=CTABLE_&label data=FITS2 force; run;
%end;
proc delete data=FITS1 FITS2 concord iauc; run; quit;
%end;
sasfile WORK.CTABLE_&label close;
proc sort data=CTABLE_&label; by descending BIC_&label; run;
data CTABLE_&label;
set CTABLE_&label point=nobs nobs=nobs;
output;
stop;
run; /*choose the last observation with minimum BIC*/
%mend DeleteOneVar;
%PUT ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
%outcome;
%PUT ======MONITORING: %SYSFUNC(DATE(),YYMMDD10.), %LEFT(%SYSFUNC(TIME(),HHMM8.))======;
*Create permanent dataset;
%let LABEL= death; /*labels for outcomes*/
data savedata.BICsim_c25_&label; set BICsim_&label; proc sort; by sim; run;
proc delete data=BICsim_&label; run; quit;
***************************************************** END BACKWARD ELIMINATION 4 INDIVIDUAL OUTCOMES: DEATH ******************************************************************;
/***********************************************************************************************************************************************************************************/
/***********************************************************************************************************************************************************************************/
/*Get Union and Intersection Model and compute summary statistics*/
/*Merge all 4 datasets with the best individual model within each outcome for each simulated dataset*/
data BICsim;
merge savedata.BICsim_c25_adl savedata.BICsim_c25_iadl savedata.BICsim_c25_walk savedata.BICsim_c25_death;
by sim;
run;
data bicsimind_sce1c25 (drop=delims i x: n i temp);
set BICsim ;
length union inters $1000;
array x{39} $ 32; /*maximum of 39 predictors in Full model*/
n=0;
do i=1 to countw(VARINMODEL_adl,' ');
temp=scan(VARINMODEL_adl,i,' ');
if temp not in x then do; n+1; x{n}=temp; end;
end;
do i=1 to countw(VARINMODEL_iadl,' ');
temp=scan(VARINMODEL_iadl,i,' ');
if temp not in x then do; n+1; x{n}=temp; end;
else if temp in x and indexw(VARINMODEL_walk,temp) and indexw(VARINMODEL_death,temp) then inters=catx(' ',inters,temp);
end;
do i=1 to countw(VARINMODEL_walk,' ');
temp=scan(VARINMODEL_walk,i,' ');
if temp not in x then do; n+1; x{n}=temp; end;
end;
do i=1 to countw(VARINMODEL_death,' ');
temp=scan(VARINMODEL_death,i,' ');
if temp not in x then do; n+1; x{n}=temp; end;
end;
union=catx(' ',of x{*});
delims = ' ';
numVarsfinsim_union=countw(union, delims);
numVarsfinsim_inters=countw(inters, delims);
numVarsfinsimadl=countw(VARINMODEL_adl, delims);
numVarsfinsimiadl=countw(VARINMODEL_iadl, delims);
numVarsfinsimwalk=countw(VARINMODEL_walk, delims);
numVarsfinsimdeath=countw(VARINMODEL_death, delims);
run;
*Summary stats of models from simulated dataset models by outcome;
proc means data=bicsimind_sce1c25 stackodsoutput n mean stderr clm median p25 p75 maxdec=4;
var numVarsfinsimadl numVarsfinsimiadl numVarsfinsimwalk numVarsfinsimdeath numVarsfinsim_union numVarsfinsim_inters C_adl C_iadl C_walk C_death iauc_adl iauc_iadl iauc_walk iauc_death VARSEC_adl VARSEC_iadl VARSEC_walk VARSEC_death ;
ods output summary=bicsimind_sce1c25_stats(rename=(Mean=Mean_sim_Ind));
proc sort; by variable; run;
PROC EXPORT DATA= bicsimind_sce1c25_stats
OUTFILE= "path\bicsimind_sce1c25_stats.csv"
DBMS=CSV REPLACE;
PUTNAMES=YES;
RUN;