Transcription of PROC REPORT- a better way to display data
1 By David-Erick Lafontant, report - A better WAY TO display DATA1 Outline ProcReport & ProcPrint Why ProcReport What else can proc report do? Examples Examples And More Examples2 Example DatadataCars;set ;run;428 obs15 variables 3 ProcReport & ProcPrint Procedures which allows one to display dataprocprintdata=cars (obs=5);var make model weight;run;procreportdata =cars(obs=5) nowd;columnmake model weight;run;4 Advantages of Knowing ProcReport Jobs Saves Time Reduces Coding Bypass many procedures Awesome display ITS JUST FUN! Resume 1 Name: Eddard StarkSkills: R Packes, C++, JAVA,SAS, Microsoft Word, Power Point,I have 25 Doctorate degreesI can work 23 hours a day $1/per hourResume 2 Name: Daenerys TargaryenSkills: PROC REPORT5 ProcReport ProcReport can do a lot more. ProcReport Combines: ProcPrint ProcSort ProcMeans ProcFreq ProcTabulate6 What else can ProcReport do? Group a variable by its Values Transpose a variable (from long format to wide format ) Summary Statistics Indentations Skip or add sentences before or after each group.
2 Improvements to display (Colors, Highlighting) Basically can do lots of things normally done using =cars(obs=50) nowd ;columnMake Model MSRP Cylinders MPG_City;defineMake / display ;run;procreportdata =cars(obs=50) nowd ;columnMake Model MSRP Cylinders MPG_City;defineMake / Group;run;12 Transpose a variable procreportdata =cars(obs=50) nowd ;columnMake Model Origin MSRP MPG_City;defineMake / Group;defineModel / Group;defineOrigin / across;run;13 Transpose and group variablesprocreportdata =cars(obs=50) nowd ;columnMake Model origin, (MSRP MPG_City);defineMake / Group;defineModel / display ;defineorigin / across;run; 14 Skip a line or add a text after each groupprocreportdata =cars(obs=50) nowdout=haha;columnMake Model origin, (MSRP MPG_City);defineMake / Group;defineModel / display ;defineorigin / across;ComputeafterMake;Line" Next Car";endcomp;run;Can put Either beforeor after15procreportdata=cars(obs=50) nowdout=haha;columnMake Model origin, (MSRP MPG_City);defineMake / Groupnoprint;defineModel / display ;defineorigin / across;ComputebeforeMake;Line@5 Make $50.
3 ;endcomp;run;Use a variable instead of a text16 Datacars2;setcars;by make;if +1; elseline + 0;run;procreportdata=cars2(obs=50) nowdout=haha;columnLine Make Model origin, (MSRP MPG_City);defineLine / groupnoprint;defineMake / Group; defineModel / display ;defineorigin / across;Computebeforea;lengthText $50;if Line = 1thentext = "This Car is Asian";elseif Line = 2thenText = "This Car is European ";elseIf Line = 3thenText = "I Love this car but I cannot afford it";elsetext = "If Oprah was here, each of us would get one";Line@1 Text $50.;endcomp;run;Add a Different Line after each groupData Step To create a variable called line which has a different value for each Make Create a variable called Text and allow a length of 50 Create a text for each group17procreportdata=cars2(obs=50) nowdout=haha;columnMake Model origin, (MSRP MPG_City);defineMake / Group; defineModel / display ;defineorigin / across;ComputebeforeMake;lengthText $50;if Make = "Acura"thentext = "This Car is Asian";elseif Make = "Audi"thenText = "This Car is European ";elseIf Make = "BMW"thenText = "I Love this car but I cannot afford it";elsetext = "If Oprah was here, each of us would get one";Line@1 Text $50.
4 ;endcomp;run;If possible bypass datastep1819procreportdata=cars(obs=50) nowdout=haha;columnMake Model origin, (MSRP MPG_City);defineMake / Group;defineModel / display ;defineorigin / across;breakafterMake / summarize;run;Add Summary After display (sum) 20 Summarize (sum) procreportdata=cars nowd;columnMake Origin,(MSRP MPG_City);defineMake / group;defineOrigin / across;run;procreportdata=cars nowd;columnMake Origin,(MSRP MPG_City);defineMake / group;defineOrigin / across;definemsrp/ sum;defineMPG_City/ sum;run;21 Summarize (other statistics) procreportdata=cars nowd;columnMake Origin, (MSRP MPG_City);defineMake / group;defineOrigin / across;definemsrp/ median;defineMPG_City/ Mean;run;Other statistics:Mean, Median, StdP90, Min, Max Sum , CV (coefficient of variation), T, PrTAny summary statistics obtainablein needs Procmeans when you can do thisprocreportdata =cars(obs=50) nowd ;Title"MSRP Summary Statistics";columnMake MSRP MSRP= MSRPN MSRP = MSRP meanMSRP =MSRPstdMSRP = MSRPminMSRP = MSRPmax;defineMake / Group;defineMSRP / analysissum noprint"Sum";defineMSRPN / analysisN "N" format =2.
5 ;defineMSRP mean/ analysismean"Mean";defineMSRPstd/ analysisstd "Std. Dev.";defineMSRPmin/ analysismin "Min";defineMSRPmax/ analysismax "Max";run;23procreportdata=cars(obs=50) nowd;columnMake origin, (MSRP MSRP=MSRPN MSRP=MSRP meanMSRP=MSRPstd);defineMake / Group;defineorigin / across;defineMSRP / analysissumnoprint"Sum";defineMSRPN / analysisN "N" format =2.;defineMSRP mean/ analysismean"Mean";defineMSRPstd/ analysisstd"Std. Dev.";run;Summary Statistics under a transposed variable24 Highlighting values procformat; valuescoreTwo0< -15= 'lightgreen 20-26= 'lightred'; run;procreportdata =cars nowd ;columnMake Origin, (MSRP MPG_City);defineMake / group;defineOrigin / across;definemsrp/ mean;defineMPG_city/ median;computeMPG_City;calldefine(_col_, 'style',"STYLE=[BACKGROUND=scoretwo.]"); endcomp;run;25procformat; valuescoreTwo0< 'lightgreen'.001< 'lightred'; run;procreportdata=cars(obs=50) nowd;columnMake origin, (MSRP MSRP= MSRPN MSRP = MSRP meanMSRP = MSRPprt);defineMake / Group;defineorigin / across;defineMSRP / analysissum noprint"Sum";defineMSRPN / analysisN "N" format =2.
6 ;defineMSRP mean/ analysismean"Mean";defineMSRPprt/ analysisprt format =pvalue."P- value";computeMSRPprt;calldefine(_col_,' style',"STYLE=[BACKGROUND=scoretwo.]") ;endcomp;run;26 Back to Editorial display The following can be targeted both in groups or individually Headers: Denotes all column headers, including spanned headers. Columns: Denotes the cells in all the columns report : Denotes the structural, or underlying, part of the report Lines: Denotes all LINE statements in all COMPUTE blocks Summary: Denotes all of the default summary lines that are produced by a BREAK or an RBREAK statement Each of the above can be edited in: Border Font Background Colors More27procreportdata= Cars(obs=10) nowdstyle( report )=[background=greenstyle (column)=[background=yellow]style(header )=[background=pink];column(" "(Make)) (Type model Origin,(MsRPInvoice));DefineMake /"Make /(1)"grouporder=data ;definemodel /"Model /(3)" display ;defineType /"Type /(2)"group;defineOrigin /"Origin /(4)"across;defineMSRP /"MSRP /(5)" display ;defineINVOICE /"Invoice /(6)";run;28procreportdata= Cars(obs=10) nowdstyle( report )=[background=green cellspacing=10style(column)=[background= yellow]style(header)=[background=pink].] ]
7 Column(" "(Make)) (Type model Origin,(MsRPInvoice));DefineMake /"Make /(1)"grouporder=data ;definemodel /"Model /(3)" display ;defineType /"Type /(2)"group;defineOrigin /"Origin /(4)"across;defineMSRP /"MSRP /(5)" display ;defineINVOICE /"Invoice /(6)";run;cellspacing/* the space between table cells, allows background to show */29procreportdata= Cars(obs=10) nowdstyle(header)=[borderstyle=solid just=centerfont_face=Arial font_size=8pt background=white cellpadding=12borderbottomcolor=black ] style( report ) =[borderstyle=solid frame=boxfont_face=Arial font_size=8pt just=left cellpadding=2]style(column)=[borderstyle =solid just=centerfont_face=Arial font_size=8pt background=white borderbottomwidth=1pt bordertopcolor=black];Edit Groups of Columnsframe = box /* outside borders: void, box, above/below, vsides/hsides, lhs/rhs*/rules = all /* internal borders: none, all, cols, rows, groups */cellpadding= 4pt /* the space between table cell contents and the cell border */background = color_list('bgT' ) /* table background color */30 Edit Individual ColumnsdefineMake /"Make /(1)"grouporder=data style(column)=[cellwidth= just=left] missing;definemodel /"Model /(3)"displaystyle(column)=[cellwidth= just=left] missing;defineType /"Type /(2)"groupstyle(column)=[cellwidth= just=left] missing;defineOrigin /"Origin /(4)"acrossstyle(column)=[cellwidth= ];defineMSRP /"MSRP /(5)"displaystyle(column)=[cellwidth= ];defineINVOICE /"Invoice /(6)"style(column)=[cellwidth= ];31 Questions?
8 ?32