%let pgm=Sug_DemRpt; /*--------------------------------------------------------------*\ | | | Template for a very complex general report | | | | (Chose the techniques you like ) | | ( or use this as a template) | | | | Strategy | | | | 1. Define your Major and Minor Headings and columns | | and create formats | | | | Grp-1 Grp-2 | | ===== ===== | | Major Group | | | | Minor Group | | | | ===================================================== | | | | Examples | | Trt-1 Trt-2 .... | | ===== ===== | | Body System n(%) n(%) | | | | Subsystem n(%) n(%) | | | | or | | | | Sex | | Male n(%) n(%) | | Female | | | | or | | | | Age | | Mean(Sd) 56(10%) 58(11%) | | Median 52 56 | | | | | | Baseline %Change From Baseline | | ======== ===================== | | WBC | | | | Mean 222.6 34% | | | | | | | | 2. Separate the Classification variables from | | the univariate variables | | | | 3. Ask for all possible univariate statistics | | (Use an X in column 6 of format for report subset) | | | | 4. Use SQL to get the N(%) values and | | concatenate the univariate output | | | | 5. Use Proc Report lke a dumb proc print to | | create final report. | | | | 6. Do report another time to show report concatenation | | and dual page numbering. | | | | | \*--------------------------------------------------------------*/ /* # # # ### #### ### ### ## ## # # # # # # # # # # # # # # # # # # # # # # # ##### # #### # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ### # # ### ### */ %Macro Tut_SmrFmt(RptTyp=Dem); /* #### #### ### ### # # # # # # # # # # # # # # # #### #### # # # # # # # # # # # # # # # # # # # ### ### # # ##### # # # ### ## ## # # # ## # # # # # # # # # # # # # # # #### ##### # ## # # # # # # # # # # # # # # # # # # # # ##### # # # # ### ##### ##### # # #### # # ##### ##### # # ## ## # # # # # # # # # # # # # # # # # # # # #### # # #### # ##### # #### # # # # # # # # # # # # # # # # # # # # # ##### # # # ##### # # # ##### */ /*--------------------------------------------------------------*\ | | | Template for for 'proc means' statistics for | | demographic clinical table | | | \*--------------------------------------------------------------*/ %If %upcase(&RptTyp.) = DEM %Then %Do; ODS PATH WORK.Templat(UPDATE) SASHELP.Tmplmst(READ); proc template; edit Base.summary; edit UCLM; format= comma8.2 ; end; edit LCLM; format= comma8.2 ; end; edit range ; format= comma8.2 ; end; edit css ; format= comma8.2 ; end; edit skew ; format= comma8.2 ; end; edit cv ; format= comma8.2 ; end; edit stddev; format= comma8.2 ; end; edit stderr ; format= comma8.2 ; end; edit sum ; format= comma8.2 ; end; edit max ; format= comma8.2 ; end; edit mean ; format= comma8.2 ; end; edit min ; format= comma8.2 ; end; edit nmiss ; format= comma8. ; end; edit median ; format= comma8.2 ; end; edit q1 ; format= comma8.2 ; end; edit q3 ; format= comma8.2 ; end; edit p1 ; format= comma8.2 ; end; edit p90 ; format= comma8.2 ; end; edit p5 ; format= comma8.2 ; end; edit p95 ; format= comma8.2 ; end; edit p10 ; format= comma8.2 ; end; edit p99 ; format= comma8.2 ; end; edit qrange ; format= comma8.2 ; end; edit probt ; format= comma8.2 ; end; edit t ; format= comma8.2 ; end; edit uss ; format= comma8.2 ; end; edit n ; format= comma8. ; end; end; run; %End; %Mend Tut_SmrFmt; /* #### ##### ##### # # # # # # # # #### # #### # # # # # # # # # # # # ##### ##### # # #### # # ##### ##### # # ## ## # # # # # # # # # # # # # # # # # # # # #### # # #### # ##### # #### # # # # # # # # # # # # # # # # # # # # # ##### # # # ##### # # # ##### */ %Macro Tut_RtfSty ( style=TrgRtf, frame=hsides, rules=groups, bottommargin=.75in, topmargin=.75in, rightmargin=1.25in, leftmargin=1.25in ) / Des="SAS Rtf Template for Target"; Proc Template; define style &Style; parent=styles.rtf; replace fonts / 'docFont' =("Arial",10.1pt) 'FixedFont' =("Courier",10.1pt) 'BatchFixedFont' =("Courier",10.1pt) 'FixedStrongFont' =("Courier",10.1pt) 'FixedHeadingFont' =("Courier",10.1pt) 'FixedEmphasisFont' =("Courier",10.1pt) 'EmphasisFont' =("Arial",10pt) 'HeadingEmphasisFont'=("Arial",10pt,Bold) 'StrongFont' =("Arial",10.1pt) 'HeadingFont' =("Arial",10.1pt,Bold) 'TitleFont' =("Arial",10.1pt,Bold) 'TitleFont2' =("Arial",10.1pt,Medium) ; style table from table / protectspecialchars=off frame=&frame rules=&rules font=fonts('docFont') borderwidth = .1pt cellpadding = 1pt cellspacing = 1pt; replace HeadersAndFooters from Cell / font = fonts('docFont') foreground=colors('datafg') background=colors('databg') protectspecialchars=off; replace SystemFooter from TitlesAndFooters / font=fonts('docFont') protectspecialchars=off just=c; replace body from Document / bottommargin=&bottommargin topmargin =&topmargin rightmargin =&rightmargin leftmargin =&leftmargin protectspecialchars=off ; end; run; quit; %Mend Tut_RtfSty; /* ### #### ##### # ##### ##### # # # # # # # # # # # # # # # # # # #### #### ##### # #### # # # # # # # # # # # # # # # # # ### # # ##### # # # ##### #### # ##### # # # # # # # # # # # # # # # # # ##### # ##### # # # # # # # # # # # # # # #### # # # # # */ /* Input Data *Utl_ConMaxMin(DemRaw); * Macro utility for this Min,Max report ; Contents Plus for DemRaw Value Value Variable Description(Label) Min Max Type Lenth TRT Treatment 1 6 num 8 PAT Patient 1 805 num 8 Classification (nominal variables) Yes/No or Levels N(%) variables ENR Enrolled 0 1 num 8 ITT Intend to Treat 0 1 num 8 SEX Gender Male Female 0 1 num 8 BLA African American 0 1 num 8 ANE Ever Anemic 0 1 num 8 DIA Diabetic 0 1 num 8 EDU Bac Mas Phd 1 3 num 8 FLU Ever have the Flu 0 1 num 8 SMO Smoker 0 1 num 8 USA Usa patient 0 1 num 8 HIV Aids 0-no 1-yes 0 1 num 8 INC Income Level Lwr, Med , Upr 1 3 num 8 KID Children 0 1 num 8 MAR Married 0 1 num 8 OCC Occupation Man, Tec, Lbr 1 3 num 8 PET Type of Family Pet 1 3 num 8 POX Ever Had Chicken Pox 0 1 num 8 Univariate Variables for Mean, Max Min BPD Diastolic Blood Pressure 3 998.0 num 8 BPS Systolic Blood Pressure 0 997.0 num 8 AGE Age 1 99.0 num 8 ALT Alt Lab Value 0 999.0 num 8 AST AST Lab Value 3 998.0 num 8 BUN Urea Nitogen 0 998.0 num 8 CRE Creatinine 0 998.0 num 8 GLU Glucose 2 998.0 num 8 HGT Height 0 998.0 num 8 QOL Quality of Life Overall Score 1 998.0 num 8 RBC Red Blood Cell Count 0 998.0 num 8 WBC White Blood Cell Count 2 998.0 num 8 WGT Weight 1 999.0 num 8 */ libname TutRaw "c:\Tut"; Options ls=157 ps=51;run; /* Create Sample Data */ Data DemRaw(Label="Create Input for Simple Demographics Table"); Retain Pat 0; Label Trt = 'Treatment' Pat = 'Patient' Wgt = 'Weight' Hgt = 'Height' Bpd = 'Diastolic Blood Pressure' Bps = 'Systolic Blood Pressure' Qol = 'Quality of Life Overall Score' Wbc = 'White Blood Cell Count' Rbc = 'Red Blood Cell Count' Age = 'Age' Bun = 'Urea Nitogen' Cre = 'Creatinine' Ast = 'AST Lab Value' Alt = 'Alt Lab Value' Glu = 'Glucose' Hiv = 'Aids 0-no 1-yes' Sex = 'Gender Male Female' Usa = 'Usa patient' Itt = 'Intend to Treat' Enr = 'Enrolled' Pox = 'Ever Had Chicken Pox' Ane = 'Ever Anemic' Smo = 'Smoker' Dia = 'Diabetic' Inc = 'Income Level Lwr, Med , Upr' Occ = 'Occupation Man, Tec, Lbr' Edu = 'Bac Mas Phd' Bla = 'African American' Mar = 'Married' Kid = 'Children' Pet = 'Type of Family Pet' Flu = 'Ever have the Flu' ; Do Trt=1 to 5; Do Itr= 100000 to 100160; Pat+1; Select; when (Uniform(573791) < .3 ) Do; Inc=1; Occ=1; Edu=1;Pet=1; End; when (Uniform(589763) < .6 ) Do; Inc=2; Occ=2; Edu=2;Pet=2; End; Otherwise Do; Inc=3; Occ=3; Edu=3;Pet=3; End; End; %macro MkeVar(Lst); %Let Frq=Hiv Flu Sex Usa Itt Enr Pox Ane Smo Dia Bla Mar Kid; %Do Idx=1 %To 13; %Scan(&Lst.,&Idx.) = Int(1000*Uniform(-1)); If Uniform(78931) < .5 then %Scan(&Frq.,&Idx.)=0;Else %Scan(&Frq.,&Idx.)=1; %End; %Mend MkeVar; %MkeVar(Bpd Bps Qol Wbc Rbc Age Bun Cre Ast Alt Glu Wgt Hgt) Drop Itr SavTrt; Output; /* for Trt 1-5 */ SavTrt=Trt; Trt=6; /* replicate all data but use Trt=6 */ Output; Trt=SavTrt; End; End; Run; /* Proc Print Data=DemRaw Width=Min; run; Pat Trt Wgt Hgt Bpd Bps Qol Wbc Rbc Hiv Sex Age Bun Cre Ast Alt Glu Usa Itt Enr Pox Ane Smo Dia Inc Occ Edu Bla Mar Kid Flu 1 Pbo 314 516 480 986 915 895 397 0 1 385 628 698 434 776 868 0 1 0 1 1 1 0 LWR Man PHD 1 1 0 0 2 Pbo 69 546 31 125 733 392 687 0 0 11 652 438 362 726 184 0 1 0 0 0 1 0 UPR TEC MAS 0 0 0 0 3 Pbo 852 512 297 93 447 338 897 1 0 972 286 348 518 158 379 0 0 0 0 1 0 1 UPR TEC MAS 0 0 0 0 4 Pbo 814 367 717 978 644 653 517 1 1 959 543 747 723 977 388 1 0 1 0 0 1 1 LWR Man PHD 1 0 1 1 5 Pbo 315 731 799 955 286 518 519 0 1 804 913 979 363 612 520 0 0 0 1 1 0 1 MED LBR BAC 1 0 1 1 6 Pbo 606 464 45 365 16 417 971 1 1 368 73 343 480 176 775 1 0 1 0 1 1 1 UPR TEC MAS 0 1 0 1 7 Pbo 716 538 593 731 848 981 264 0 0 808 8 894 55 528 847 0 0 1 1 0 0 1 LWR Man PHD 0 1 0 1 8 Pbo 906 521 936 452 528 216 275 0 1 314 152 626 934 197 72 0 1 1 0 0 0 0 MED LBR BAC 1 0 1 1 9 Pbo 907 640 81 77 225 431 844 1 0 117 564 565 928 797 513 1 1 0 0 0 0 1 UPR TEC MAS 1 0 1 1 10 Pbo 818 279 128 743 858 323 732 0 0 806 191 167 695 17 125 1 1 1 1 0 1 1 LWR Man PHD 0 1 1 1 11 Pbo 452 807 235 806 301 192 699 1 1 340 28 40 469 422 547 0 1 0 1 0 0 1 LWR Man PHD 0 0 0 1 12 Pbo 627 694 891 209 700 149 73 0 0 583 658 489 323 461 758 1 1 1 1 0 1 0 MED LBR BAC 1 0 1 1 13 Pbo 405 882 958 306 986 338 459 0 0 698 490 309 799 441 527 1 0 0 0 0 0 1 MED LBR BAC 0 1 0 1 14 Pbo 525 114 319 9 379 821 252 0 0 37 949 890 886 424 11 1 1 1 0 0 0 0 LWR Man PHD 0 0 1 1 15 Pbo 805 573 336 808 307 399 739 1 0 301 348 437 236 242 318 0 1 0 0 1 0 0 MED LBR BAC 1 0 1 0 16 Pbo 810 728 492 884 994 23 869 1 1 922 764 369 665 789 47 0 0 1 0 1 1 0 LWR Man PHD 0 1 1 1 17 Pbo 401 76 885 788 892 488 605 1 1 883 215 643 898 388 124 1 1 0 1 1 1 0 MED LBR BAC 1 1 1 1 18 Pbo 692 921 395 396 426 65 927 0 1 847 248 823 68 272 533 1 1 1 1 1 1 0 UPR TEC MAS 0 0 0 1 19 Pbo 475 256 553 393 711 815 56 1 0 323 448 532 768 734 808 1 1 1 1 0 1 1 UPR TEC MAS 0 1 0 0 20 Pbo 984 598 546 401 659 970 805 1 1 671 806 517 404 61 574 1 0 1 1 1 0 1 UPR TEC MAS 0 1 0 1 21 Pbo 76 740 870 486 969 42 438 0 0 228 27 554 244 423 735 1 1 1 1 0 0 0 MED LBR BAC 0 0 0 1 22 Pbo 606 451 598 680 325 907 949 1 1 817 331 496 109 244 319 1 0 0 0 1 0 1 MED LBR BAC 0 1 1 0 23 Pbo 759 189 401 291 896 942 256 0 1 57 604 622 271 259 794 1 0 0 1 1 0 1 LWR Man PHD 1 1 0 0 24 Pbo 756 401 984 450 119 331 888 0 0 684 792 484 905 484 998 0 1 1 0 1 1 0 MED LBR BAC 1 1 0 0 25 Pbo 863 188 895 882 636 93 712 1 0 741 160 779 892 824 336 1 0 0 0 1 1 1 UPR TEC MAS 0 1 0 0 26 Pbo 109 538 336 102 599 168 566 0 1 581 509 400 951 232 283 0 0 1 0 0 1 1 LWR Man PHD 0 1 0 0 27 Pbo 380 570 933 241 542 396 948 1 0 924 818 366 616 841 462 1 0 0 0 1 1 1 LWR Man PHD 1 1 0 1 28 Pbo 885 566 779 50 194 944 579 1 1 268 594 153 555 262 799 1 1 1 1 1 0 0 UPR TEC MAS 1 0 0 1 29 Pbo 196 158 473 698 35 554 43 0 1 804 359 601 509 214 78 0 0 0 1 1 0 0 MED LBR BAC 0 0 0 1 30 Pbo 377 643 66 97 180 485 232 1 1 317 738 326 746 495 307 0 0 1 0 0 0 0 MED LBR BAC 1 0 0 1 31 Pbo 355 794 643 673 524 661 634 0 0 643 293 899 819 184 695 0 0 1 0 0 0 1 UPR TEC MAS 0 1 0 0 32 Pbo 311 370 635 322 896 627 697 1 1 751 853 3 788 276 298 0 1 1 0 0 0 0 UPR TEC MAS 1 1 1 0 33 Pbo 665 127 754 57 369 337 222 0 0 28 166 33 801 779 853 1 1 1 1 0 0 1 UPR TEC MAS 1 1 1 1 34 Pbo 958 941 714 24 727 824 261 0 0 712 165 136 351 899 766 1 0 0 1 0 0 0 MED LBR BAC 1 1 1 1 35 Pbo 589 810 654 458 489 209 253 0 1 140 854 425 211 808 672 1 0 1 0 1 0 1 LWR Man PHD 0 1 1 1 36 Pbo 799 616 359 650 407 968 7 1 0 188 444 411 69 608 981 0 1 0 1 1 1 0 LWR Man PHD 1 0 0 1 37 Pbo 600 268 135 334 337 859 585 0 1 642 415 299 544 937 8 0 1 1 0 0 0 1 UPR TEC MAS 1 1 1 0 */ /* ##### ### #### # # # ##### ### # # # # # ## ## # # # # # # # # # # # # # # # # # #### # # #### # # ##### # # # # # # # # # # # # # # # # # # # # # # # # # # ### # # # # # # # ### */ Proc Format; /*--------------------------------------------------------------*\ | | | Layout for the first Page (done by formats) | | | | First two digits are the Page, next three are order on page | | | | Definitions and location of Major Headings | | | | PgOrder Major Group | | --|| ---------------- | | 'Itt' = '010000 Intent to Treat' | | 'Enr' = '010100 Enrollment' | | 'Age' = '010200 Age | | | | Definitions and location Major and Minor Headings | | on the first page | | | | First the location of Major Headings and then the | | location of Minor headings | | | | 010000= 'Intend to Treat' | | | | 0 = 'Could not Treat' | | 1 = 'Treated' | | | | 010100= 'Enrollment' | | | | 0 = 'Not Enrolled' | | 1 = 'Enrolled' | | | | 010200= 'Age' | | | | 010200+01 (010201) = '01 X N' | | 010200+02 (010202) = '02 X Number Missing Observations' | | 010200+03 (010203) = '03 X Mean(SD)' | | 010200+04 (010204) = '04 X Median' | | | | ... | | | \*--------------------------------------------------------------*/ /*--------------------------------------------------------------*\ | | | Assign page numbers and major heading order | | | | For minor univariate statistics | | | | 'N' = '01 X N' | | 'Mean' = '03 X Mean(SD)' | | 'Median' = '06 X Median' | | 'Min' = '09 X Minimum,Maximum' | | | | add the two digit numbers to the major heading order | | | | for nominal data we add the raw data numeric values | | | \*--------------------------------------------------------------*/ value $Mjr2Des /* Page 1 */ 'Itt' = '010000 Intend to Treat' 'Enr' = '010400 Enrollment' 'Age' = '011000 Age' /* Page 2 */ 'Usa' = '020800 Usa Patient' 'Mar' = '021200 Married' 'Qol' = '021400 Quality of Life Overall Score' /* Page 3 */ 'Kid' = '031600 Children' 'Pet' = '032000 Type of Family Pet' 'Wbc' = '032200 White Blood Cell Count' /* Page 4 */ 'Sex' = '042400 Gender Male Female' 'Inc' = '042800 Income Level Lower Third , Middle Third, Upper Third' 'Cre' = '043000 Creatinine' /* Page 5 */ 'Occ' = '053200 Occupation Manager, Technician, Laborer' 'Edu' = '053600 Educational Level Bachelors, Masters and Phd' /* Page 6 */ 'Bla' = '064000 African American' 'Hiv' = '064400 Aids 0-no 1-yes' 'Bps' = '064600 Systolic Blood Pressure' /* Page 7 */ 'Pox' = '074800 Ever Had Chicken Pox' 'Ane' = '075200 Ever Anemic' 'Rbc' = '075400 Red Blood Cell Count' /* Page 8 */ 'Smo' = '085600 Smoker' 'Dia' = '086000 Diabetic' 'Glu' = '086200 Glucose' /* Page 9 */ 'Flu' = '096400 Ever have Flu' 'Ast' = '096500 AST Lab Value' 'Alt' = '096600 Alt Lab Value' /* Numeric data Major Headings */ /* Page 10 */ 'Bun' = '100400 Urea Nitogen' 'Wgt' = '100800 Weight' /* Page 11 */ 'Hgt' = '110400 Height' 'Bpd' = '110800 Diastolic Blood Pressure' ; /* Numeric data minor headings position within major headings */ /* Assign order and selection */ value $Mnr2Des 'N' = '01 X N' 'NMiss' = '02 Number Missing' 'Mean' = '03 X Mean(SD)' 'LCLM' = '04 Lower and Upper 95% CI on Mean' 'UCLM' = '05 UCLM' 'Median' = '06 X Median' 'StdDev' = '07 Standard Deviation' 'Var' = '08 Var' 'Min' = '09 X Minimum,Maximum' 'Max' = '10 Max' 'Range' = '11 Range' 'Q1' = '12 Q1' 'Q3' = '13 Q3' 'Q1Q3' = '14 Q1,Q3' 'QRange' = '15 Quartile Range' 'StdErr' = '16 Standard Error of Mean' 'Skew' = '17 Skew' 'CV' = '18 Coef of Variation 100*StdDev/Mean' 'Sum' = '19 Sum' 'CSS' = '20 CSS' 'USS' = '21 USS' 'P1' = '22 1st, 99th Percentile' 'P5' = '23 5th, 95th Percentile' 'P10' = '24 10th, 90th Percentile' 'P90' = '25 P90' 'P95' = '26 P95' 'P99' = '27 P99' 'Probt' = '28 Probt' 't' = '29 t' Other = '00 ' ; Value $Num2Trt '_1'='Valtrx' '_2'='Placebo' '_3'='Aspirin' '_4'='Codeine' '_5'='Vertex' '_6'='All' ; Value Inc2Lvl 1='Lower Third in Income' 2='Middle Third in Income' 3='Upper Third in Income'; Value Edu2Lvl 1='Bachelors Degree' 2='Masters Degree' 3='Phd'; Value Pet2Lvl 1='Dog for Family Pet' 2='Cat for Family Pet' 3='Fish for Family Pet'; Value Occ2Lvl 1='Manager' 2='Technical' 3='Laborer'; Value Hiv2Lvl 0='HIV Positive' 1='HIV Negative'; Value Sex2Lvl 0='Male' 1='Female'; Value Itt2Lvl 0='Could Not Treat' 1='Treated'; Value Usa2Lvl 0='US Citizen' 1='Foreign National'; Value Enr2Lvl 0='Enrolled' 1='Not Enrolled'; Value Pox2Lvl 0='Had Cicken Pox' 1='No Chicken Pox'; Value Ane2Lvl 0='Anemic' 1='Not Anemic'; Value Smo2Lvl 0='Smoker' 1='Non Smoker'; Value Dia2Lvl 0='Diabetic' 1='Not Diabetic'; Value Bla2Lvl 0='African American' 1='Not African American'; Value Mar2Lvl 0='Married' 1='Single'; Value Kid2Lvl 0='Children' 1='No Children'; Value Flu2Lvl 0='Influenza' 1='No Influenza'; run; Ods Exclude All; /*--------------------------------------------------------------*\ | | | Classification Variables like Sex | | | \*--------------------------------------------------------------*/ /* Create long and skinny normalized data */ /* Take care of nominal variables ie Sex, Race */ Proc Transpose Data=DemRaw Out=DemXpoNom ; by Pat Trt; Var Inc Edu Pet Occ Hiv Flu Sex Usa Itt Enr Pox Ane Smo Dia Bla Mar Kid; run; /* Output of Transpose (27,000+ lines) Long and skinny options nocenter; Proc Print data=DemXpoNom width=min; run; Obs Pat Trt _NAME_ _LABEL_ COL1 1 1 1 Inc Income Level Lwr, Med , Upr 2 ** codes see format 2 1 1 Edu Bacalaurate Masters Phd 2 3 1 1 Pet Type of Family Pet 2 4 1 1 Occ Occupation Man, Tec, Lbr 2 5 1 1 Hiv Aids 0-no 1-yes 1 6 1 1 Flu Ever have the Flu 1 7 1 1 Sex Gender Male Female 1 8 1 1 Usa Usa patient 0 9 1 1 Itt Intend to Treat 0 10 1 1 Enr Enrolled 1 11 1 1 Pox Ever Had Chicken Pox 0 12 1 1 Ane Ever Anemic 0 13 1 1 Smo Smoker 1 14 1 1 Dia Diabetic 0 15 1 1 Bla African American 0 16 1 1 Mar Married 1 17 1 1 Kid Children 1 18 1 6 Inc Income Level Lwr, Med , Upr 2 */ /*--------------------------------------------------------------*\ | | | Univariate Variables like Weight | | | \*--------------------------------------------------------------*/ /* Take Care of the ordinal variables height weight age etc */ ods output Summary=DemUnv; Proc Means Data=DemRaw clm range css skew cv std kurt stderr sum max mean min uss n var nmiss median q3 p1 p90 p5 p95 p10 p99 q1 qrange probt t ; Class Trt; Var Bpd Bps Qol Wbc Rbc Age Bun Cre Ast Alt Glu Wgt Hgt; Run; Ods output close; ods select all; Proc Transpose Data=DemUnv Out=DemUnvLng; by Trt; Var _Numeric_; Run; /* Output of Transpose for ordinal variables Long and skinny options nocenter; Proc Print data=DemUnvLng width=min; run; * Bpd is blood pressure (diastolic) * Trt _NAME_ _LABEL_ COL1 1 Trt Treatment 1.00 1 NObs N Obs 161.00 1 Bpd_LCLM Lower 95% CL for Mean 437.93 1 Bpd_UCLM Upper 95% CL for Mean 525.39 1 Bpd_Range Range 974.00 1 Bpd_CSS Corrected SS 12631956.21 1 Bpd_Skew Skewness 0.17 1 Bpd_CV Coeff of Variation 58.34 1 Bpd_StdDev Std Dev 280.98 1 Bpd_Kurt Kurtosis -1.11 1 Bpd_StdErr Std Error 22.14 1 Bpd_Sum Sum 77547.00 1 Bpd_Max Maximum 981.00 1 Bpd_Mean Mean 481.66 1 Bpd_Min Minimum 7.00 1 Bpd_USS Uncorrected SS 49983119.00 1 Bpd_N N 161.00 1 Bpd_Var Variance 78949.73 1 Bpd_NMiss N Miss 0.00 1 Bpd_Median Median 440.00 1 Bpd_Q3 Upper Quartile 710.00 1 Bpd_P1 1st Pctl 8.00 1 Bpd_P90 90th Pctl 878.00 1 Bpd_P5 5th Ptcl 60.00 1 Bpd_P95 95th Pctl 938.00 1 Bpd_P10 10th Pctl 114.00 1 Bpd_P99 99th Pctl 974.00 1 Bpd_Q1 Lower Quartile 263.00 1 Bpd_QRange Quartile Range 447.00 1 Bpd_Probt Pr > |t| 0.00 1 Bpd_t t Value 21.75 1 Bps_LCLM Lower 95% CL for Mean 460.82 1 Bps_UCLM Upper 95% CL for Mean 554.00 1 Bps_Range Range 990.00 1 Bps_CSS Corrected SS 14338452.94 1 Bps_Skew Skewness -0.09 1 Bps_CV Coeff of Variation 59.00 */ Proc Sql; /*--------------------------------------------------------------*\ | | | Create six macro variables _1, _2 .._6 for column headers | | | | _1 = Placebo | | (N=161) | | | | _2 = Aspirin | | (N=161) | | | | ... | \*--------------------------------------------------------------*/ Select Resolve('%Let _'!!Put(Trt,1.)!!'=%Sysfunc(Putc(_'!!Put(Trt,1.)!!',$Num2Trt.))#(N='!!Put(Count(Trt),4.)!!');') as Dum from DemRaw Group by Trt; Create Table DemPre as /*--------------------------------------------------------------*\ | | | Classification Variables | | | | 1. Create descriptions and oder variable using format lookups | | Major and Minor breaking and ordering variables | | 2. Compute N(%) | | | \*--------------------------------------------------------------*/ Select Det.Trt, Input(SubStr(Put(Det._name_,$Mjr2Des.),1,2),2.) as Hed, /* Page Number */ Calculated Hed as Fot, /* Page Number same as Hed SAS Bug Fix */ SubStr(Put(Det._name_,$Mjr2Des.),8) as Mjr, /* Major Heading */ '\R\b \li360 '!!Putn(Det.Col1,compress(Det._name_!!'2Lvl40.')) as Mnr Length=154 , /* Minor Heading */ Input(SubStr(Put(Det._name_,$Mjr2Des.),1,6),9.) as Odr, compress(Put(Sum(Det.Col1 ne .),8.)!!'('!!Put(100*Sum(Det.Col1 ne .)/All.Tot,8.1)!!'%)') as Val length=32 From DemXpoNom as Det, (Select Sum(Col1 ne .) as Tot, Trt, _Name_ From DemXpoNom Group by Trt, _Name_) as All Where Det.Trt = All.Trt and Det._Name_=All._Name_ Group by Det.Trt, Calculated Hed, Calculated Fot, Calculated Mjr, Calculated Mnr, Calculated Odr Union All /*--------------------------------------------------------------*\ | | | Univariate Variables | | | | 1. Create descriptions and oder variable using format lookups | | Major and Minor breaking and ordering variables | | 2. Format Means(SD), (Min,Max) | | | \*--------------------------------------------------------------*/ Select One.Trt, Input(SubStr(Put(substr(one._name_,1,3),$Mjr2Des.),1,2),2.) as Hed, Calculated Hed as Fot, SubStr(Put(substr(one._name_,1,3),$Mjr2Des.),8) as Mjr, '\R\b \li360 '!!SubStr(Put(substr(one._name_,5),$Mnr2Des.),6) as Mnr, Input(SubStr(Put(substr(one._name_,1,3),$Mjr2Des.),1,6),9.) + Input(SubStr(Put(substr(one._name_,5),$Mnr2Des.),1,2),9.) as Odr, Case When (substr(One._Label_,1,1)='N') then Put(One.Col1,8.) When ( One._Label_='Minimum') then compress('('!!Put(One.Col1,8.2)!!','!!Put(Max.Col1,8.2)!!')') When ( One._Label_='Mean' ) then compress('('!!Put(One.Col1,8.2)!!','!!Put(Sd.Col1,8.2)!!')' ) When ( One._Label_='Lower Quartile') then compress('('!!Put(One.Col1,8.2)!!','!!Put(Q3.Col1,8.2)!!')' ) When ( One._Label_='5th Ptcl') then compress('('!!Put(One.Col1,8.2)!!','!!Put(P95.Col1,8.2)!!')') When ( One._Label_='10th Pctl') then compress('('!!Put(One.Col1,8.2)!!','!!Put(P90.Col1,8.2)!!')') When ( One._Label_='1st Pctl') then compress('('!!Put(One.Col1,8.2)!!','!!Put(P99.Col1,8.2)!!')') When ( One._Label_='Lower 95% CL for Mean') then compress('('!!Put(One.Col1,8.2)!!','!!Put(Uclm.Col1,8.2)!!')') Else Put(One.Col1,8.2) End as Val length=32 From DemUnvLng as One, DemUnvLng(Where=(_Label_='N Obs')) as Nob, DemUnvLng(Where=(_Label_='Maximum')) as Max, DemUnvLng(Where=(_Label_='Std Dev')) as SD, DemUnvLng(Where=(_Label_='95th Pctl')) as P95, DemUnvLng(Where=(_Label_='90th Pctl')) as P90, DemUnvLng(Where=(_Label_='99th Pctl')) as P99, DemUnvLng(Where=(_Label_='Upper Quartile')) as Q3, DemUnvLng(Where=(_Label_='Upper 95% CL for Mean')) as Uclm Where One.Trt=Nob.Trt and One.Trt=Max.Trt and Substr(One._Name_,1,3)=Substr(Max._Name_,1,3) and One.Trt=Q3.Trt and Substr(One._Name_,1,3)=Substr(Q3._Name_,1,3) and One.Trt=Sd.Trt and Substr(One._Name_,1,3)=Substr(Sd._Name_,1,3) and One.Trt=P95.Trt and Substr(One._Name_,1,3)=Substr(P95._Name_,1,3) and One.Trt=P99.Trt and Substr(One._Name_,1,3)=Substr(P99._Name_,1,3) and One.Trt=P90.Trt and Substr(One._Name_,1,3)=Substr(P90._Name_,1,3) and One.Trt=Uclm.Trt and Substr(One._Name_,1,3)=Substr(Uclm._Name_,1,3) and Substr(Put(substr(one._name_,5),$Mnr2Des.),4,1) eq 'X' Order by Odr, Hed, Fot, Mjr, Mnr, Trt ; Select Max(Hed) into :MaxPge from DemPre; quit; run; /* Macro headings for columns %Put Trt 1 = &_1; %Put Trt 2 = &_2; %Put Trt 3 = &_3; %Put Trt 4 = &_4; %Put Trt 5 = &_5; %Put Trt 6 = &_6; '#' is the split character Trt 1 = Vze#(N= 161) Trt 2 = Pbo#(N= 161) Trt 3 = Asa#(N= 161) Trt 4 = Apc#(N= 161) Trt 5 = Pot#(N= 161) Trt 6 = All#(N= 805) Proc Print Data=Dempre width=min; run; Obs Trt Hed Fot Mjr Mnr Odr Val 1 1 1 1 Intent to Treat \R\b \li360 Could Not Treat 1000000000 68(42.2%) 2 2 1 1 Intent to Treat \R\b \li360 Could Not Treat 1000000000 90(55.9%) 3 3 1 1 Intent to Treat \R\b \li360 Could Not Treat 1000000000 95(59.0%) 4 4 1 1 Intent to Treat \R\b \li360 Could Not Treat 1000000000 75(46.6%) 5 5 1 1 Intent to Treat \R\b \li360 Could Not Treat 1000000000 69(42.9%) 6 6 1 1 Intent to Treat \R\b \li360 Could Not Treat 1000000000 397(49.3%) 981 1 11 11 Glucose \R\b \li360 10th, 90th Percentile 1129001230 (126.00,933.00) 982 2 11 11 Glucose \R\b \li360 10th, 90th Percentile 1129001230 (126.00,834.00) 983 3 11 11 Glucose \R\b \li360 10th, 90th Percentile 1129001230 (126.00,884.00) 984 4 11 11 Glucose \R\b \li360 10th, 90th Percentile 1129001230 (86.00,903.00) 985 5 11 11 Glucose \R\b \li360 10th, 90th Percentile 1129001230 (99.00,821.00) 986 6 11 11 Glucose \R\b \li360 10th, 90th Percentile 1129001230 (109.00,884.00) */ Proc Transpose Data=DemPre Out=DemPreXpo(Drop=_Name_); by Odr Hed Fot Mjr Mnr; Var Val; Id Trt; Run; Title; Footnote; Run; /* Margins and style ### ##### # # # ##### # # # # # # # # # # # # # # # # # #### # # # # # # # # # # # ### # # ##### ##### # # ##### # # # ### ## ## # # # ## # # # # # # # # # # # # # # # #### ##### # ## # # # # # # # # # # # # # # # # # # # # ##### # # # # ### ##### ##### # # #### # # ##### ##### # # ## ## # # # # # # # # # # # # # # # # # # # # #### # # #### # ##### # #### # # # # # # # # # # # # # # # # # # # # # ##### # # # ##### # # # ##### */ /* decimal places for proc means output Updates default template */ %Tut_SmrFmt; %Tut_RtfSty ( style=TutRtf, bottommargin=.25in, topmargin=.25in, rightmargin=.75in, leftmargin=.75in ); Options nodate nonumber orientation=landscape ls=255;run; %Let DatTym=%Sysfunc(Putn(%qSysfunc(Datetime()),datetime18.)); %Let RtfOt1=%str(c:\Tut\Tut_DemRptNew.rtf); ods rtf file="&RtfOt1." style=TutRtf; ods escapechar='^';run; title .j=l 'National Association of Nephologists' .j=r 'Page ^{pageof}' .j=l "Las Vegas Nevada 2004"; footnote .j=l "Journal of the Association of Nephrology Volume 11 November 2004^R/RTF'{\line}'" "AMGEN 1 Biotech Court Thousand Oaks CA 91320"; %Let HdrTop=%str(^S={font_weight=bold font_size=10pt protectspecialchars=off cellpadding=.1pt}); %Let HdrMaj=%str(^S={font_size=10pt font_weight=bold font_style=italic protectspecialchars=off just=l}); %Let HdrBot=%str(^S={font_size=8pt font_style=italic protectspecialchars=off }); /* Create Report */ Proc Report Data=DemPreXpo nowd Split='#' Box Missing ; Cols ( "^S={}\brdrb\brdrs" Hed Fot Odr Mjr Mnr _1 _2 _3 _4 _5 _6 ) ; Define Hed / Group Noprint Order=Data; Define Fot / Group Noprint Order=Data; Define Mjr / Group Noprint Order=Data; Define Odr / Display Noprint Order=Data; Define Mnr / Display "\R\b \fs24 Statistic" ; Define _1 / Display "\R\b \fs24 &_1" style(column)={just=c}; Define _2 / Display "\R\b \fs24 &_2" style(column)={just=c}; Define _3 / Display "\R\b \fs24 &_3" style(column)={just=c}; Define _4 / Display "\R\b \fs24 &_4" style(column)={just=c}; Define _5 / Display "\R\b \fs24 &_5" style(column)={just=c}; Define _6 / Display "\R\b \fs24 &_6" style(column)={just=c}; Break Before Hed / ; Compute before _Page_ /style={just=l font_size=12pt font_weight=bold}; Line " Complex Demographic Table Produced by a User Modifiable SAS Template"; Line " Second Copy to Show Multiple Reports and Two sets of Page Numbers"; Endcomp; Break Before Mjr / ; Compute Before Mjr; MjrBol="\R\b \i \fs24 \cf13 "!!left(Mjr); line @1 MjrBol $98.; EndComp; Break After Fot / ; Compute After Fot /style={just=r font_size=8pt}; Hdr= compbl('Page '!!put( Fot, 2.)!!" of %Sysfunc(compress(&MaxPge.))"); line "^S={}\brdrt\brdrs"; Line Hdr $96.; endcomp; Break After Hed / suppress page; Compute After _Page_ / style={just=l font_size=8pt font_style=italic}; line "PGM: c:\Tut\&Pgm..sas"; line "OUT: &RtfOt1 &DatTym."; endcomp; Run; Quit; ods rtf close; run;