Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 SAS ® ODS Technology for Today’s Decision Makers Sunil Gupta Quintiles.

Similar presentations


Presentation on theme: "1 SAS ® ODS Technology for Today’s Decision Makers Sunil Gupta Quintiles."— Presentation transcript:

1 1 SAS ® ODS Technology for Today’s Decision Makers Sunil Gupta Quintiles

2 2 SAS Users Manager: Excel file, HTML drill down files Programmer: HTML, PDF, RTF Statistician: p-values, plots

3 3 Agenda  What’s Unique about ODS?  Creating Excel Files  Efficient Data Analysis with ODS  Custom Formats in RTF files  Applying Style Syntax in Proc Tabulate and Proc Print

4 4 What’s Unique about ODS?  Destinations (Remember to turn off ODS) (Defines the output file type: HTML, RTF, PDF, LISTING, OUTPUT )  Creating Output Objects (Reference to Output Object Names)  Creating Output Files with Style (Reference to ‘SAS-Supplied’ Styles) Part of SAS/Base

5 5 Defining Output Destinations ODS HTML, Excel RTF Printer: PS, PDF PCL Standard: SAS List Output: SAS Dataset

6 6 Create Demog Data Set Patient, Sex, Height, Weight, Age, Race, Drug (n=25 records)

7 7 Creating Output Files: Report Files ODS File = ’ ’; SAS Procedure(s); ODS CLOSE; Where File Type = HTML, RTF, Listing, PDF,.. Keep consistent filename types:.html, rtf, lst, pdf,.. Results of one or more SAS Procedures

8 8 Example 1a. Create Excel File – demog.xls PROC UNIVARIATE DATA=DEMOG; VAR WEIGHT; RUN;

9 9 Example 1a. Create Excel File ODS HTML FILE = 'c:\how\gupta\demog.xls’ STYLE = minimal; PROC UNIVARIATE DATA=DEMOG; VAR WEIGHT; RUN; ODS HTML CLOSE; Try this in the office - Undocumented Feature. See SAS paper on Excel and ODS. (HTML,.xls) Excel

10 10 Example 1a. Create Excel File: demog.xls Each result item is in it’s own cell!

11 11 Example 1b. Create Demog_Style HTML File with Style PROC UNIVARIATE DATA=DEMOG; VAR WEIGHT; RUN;

12 12 Example 1b. Create HTML File with Style ODS HTML FILE = 'c:\how\gupta\demog_style.html' STYLE = barrettsblue; PROC UNIVARIATE DATA=DEMOG; VAR WEIGHT; RUN; ODS HTML CLOSE;

13 13 Example 1b. Create HTML File with Style (BARRETTSBLUE)

14 14 Creating Output Files with Style “SAS Supplied” Styles (partial list) NAME DESCRIPTION BarrettsBlue Blue header background, light table background Beige Beige header text, white text in table Brick Brick color header text, white text in table Brown Brown title, black header, light table background … (see Quick Results with the Output Delivery System book) Proc Template; list styles; run;

15 15 Efficient Data Analysis with ODS  Selecting Objects  Creating Output Data sets  Creating Multiple Data sets with the MATCH_ALL option  Using Traffic Lighting conditions to identify significance  Creating Plots and Tables as RTF file

16 16 Example 2a. Create Output Data Set Measure from Basic Measures Info ODS OUTPUT = ; PROC UNIVARIATE DATA=DEMOG; VAR WEIGHT; RUN; ODS OUTPUT CLOSE;

17 17 Creating Output Objects OUTPUTOBJECTSOUTPUTOBJECTS Results of PROC UNIVARIATE MomentsBasicMeasuresTestsForLocationQuantilesExtremeObs

18 18 Identifying Output Objects: List File Output Added: ODS TRACE ON / LABEL LISTING; (One of Several Output Objects Created) Name: BasicMeasures Label: Basic Measures of Location and Variability Template: base.univariate.Measures* Path: Univariate.weight.BasicMeasures Label Path: 'The Univariate Procedure'.'weight'.'Basic Measures of Location and Variability' * Except for: Proc Print, Proc Tabulate and Proc Report.

19 19 Example 2a. Create Output Data Set Measure from Basic Measures Info ODS TRACE ON / LABEL LISTING; *ODS OUTPUT = ; PROC UNIVARIATE DATA=DEMOG; VAR WEIGHT; RUN; ODS OUTPUT CLOSE;

20 20 Example 2a. Create Output Data Set Measure from Basic Measures Info ODS OUTPUT BASICMEASURES = MEASURE; PROC UNIVARIATE DATA=DEMOG; VAR WEIGHT; RUN; ODS OUTPUT CLOSE; Proc print; run; Note: OUTPUT OUT = statement in procedures are still valid! (Data set Name)(Object Name)

21 21 Example 2a. Create Output Data Set Measure * Proc print of MEASURE Output Data Set; Measure as SAS Data set Var Loc Obs Name Measure LocValue VarMeasure VarValue 1 weight Mean 198.6800 Std Deviation 44.55682 2 weight Median 199.0000 Variance 1985 3 weight Mode. Range 159.00000 4 weight _ Interquartile Range 56.00000 Get comfortable with the output data set.

22 22 Creating Output Data Sets  Works with any SAS Procedure  All results are available in the data set  Options are available for creating multiple data sets Note: Requires having information about the object. Can use the ODS TRACE statement to get this information.

23 23 Example 2b. Create Multiple Data Sets with the MATCH_ALL option ODS OUTPUT BASICMEASURES /* object name */ (MATCH_ALL = MEASURE_DSN /* macro name */ PERSIST = PROC) /* maintain selection list */ = MEASURE; /* data set names - measure, measure1, measure2 */ PROC UNIVARIATE DATA=DEMOG; VAR WEIGHT HEIGHT; RUN; PROC UNIVARIATE DATA=DEMOG; VAR AGE; RUN; ODS OUTPUT CLOSE; %PUT Macro variable = &MEASURE_DSN;

24 24 Example 2b. Create Multiple Data Sets with the MATCH_ALL option data allmeans; set &measure_dsn; /* set measure measure1 measure2; */ where locmeasure = 'Mean'; keep varname locmeasure locvalue; run; Var Loc Obs Name Measure LocValue 1 weight Mean 198.6800 2 height Mean 66.8400 3 age Mean 56.5280

25 25 Example 3. Using Traffic Lighting low = green, high = orange proc format; value traffic low - 99 = ‘ ’ 100 - high = ‘ ’ ; quit; ods html file = ‘c:\how\gupta\print_results.htm’; proc report data=allmeans nowd; columns varname locvalue; define varname/ ‘Variable’; define locvalue / ‘Mean’ style = {background = }; run; ods html close;

26 26 Example 3. Using Traffic Lighting low = green, high = orange proc format; value traffic low - 99 = ‘green’ /* cx006600 */ 100 - high = ‘orange’ /* cxFF9900 */ ; quit; ods html file = ‘c:\how\gupta\print_results.htm’; proc report data=allmeans nowd; columns varname locvalue; define varname/ ‘Variable’; define locvalue / ‘Mean’ style = {background = traffic.}; run; ods html close;

27 27 Using Traffic Lighting Conditions to identify significance Make results visually informative. Greater Than 100

28 28 Example 4. Create Plots and Tables as Plots.rtf File ; proc univariate data = demog ; var weight; ; run; ods rtf close;

29 29 Example 4. Create Plots and Tables as Plots.rtf File ods rtf file = ’c:\how\gupta\plots.rtf’; proc univariate data = demog plots; var weight; histogram / cfill=cyan; run; ods rtf close; Plots.rtf You can have it all - tables and plots in one file!

30 30 Example 4. Creating Plots and Tables as RTF File

31 31 Customize RTF File: RTF Control Words Effect Control Word Italics \i underline \ul  bullet \bullet bold \b subscript \sub superscript \super strike \strike (http://msdn.microsoft.com/library/default.asp?url=/library/en -us/dnrtfspec/html/rtfspec.asp)

32 32 Customize RTF File: RTF Control Words 1. Carrot ‘^’ symbol is best as the escapechar symbol since the RTF syntax uses the \ symbol. 2. Use the following formula and conditions: “text” || ‘^R”\rtf-control-word text \rtf-control-word0 “’ a. Double quotes (“ ”) around “text” strings. b. Concatenate all strings with || operator. c. Use single quote (to set ‘^R) and then double quote to start rtf-control-word string (“\rtf-control-word). d. The text to be affected. e. Repeat and close each rtf-control-word string with 0, double quote (“) then single quote (‘), (\rtf-control-word0 “’).

33 33 Example 5. Custom RTF File: RTF Control Words - Title and Data Step ods escapechar = '^'; title1 '^R/RTF"\ul " Title contains underlined text'; data rtfcontrol; a = "The text uses RTF control words " || '^R"\i italic text \i0 "' || ' regular text ' || '^R"\ul underlined text \ul0 "'|| '^R"\strike strike text \strike0 "' ; run; ods rtf file = ’c:\how\gupta\rtf_control.rtf'; proc print data=rtfcontrol; run; ods rtf close; Be careful to match all quotes

34 34 Example 5. Custom RTF File: RTF Control Words - Title and Data Step Look what SAS can do - it really works! RTF

35 35 Example 6. Summary Table Using In- line Formatting Text in RTF files OPTIONS ORIENTATION=PORTRAIT nodate center; ODS ESCAPECHAR = ‘^’; /* required */ /* signals start of non SAS code - tags ex. {super a}*/ ODS RTF FILE = 'C:\how\gupta\table1.rtf' STYLE = MINIMAL /* Basic MS Word table, no color */ BODYTITLE; SAS Procedure(s) ODS RTF CLOSE; Be very careful of ODS BODYTITLE option!

36 36 Customize RTF File: Header/Footer Sections - Titles  Place font attributes before the text to apply  Syntax is different from footnote and SAS Procedures: PRINT, REPORT, and TABULATE  In version 8.2, Page X of Y feature requires print review/print to take affect. The following syntax is required: "{Page} {\field{\*\fldinst{ PAGE }}} \~{of}\~{\field{\*\fldinst { NUMPAGES }}}"

37 37 Example 6. Customize RTF File: Header/Footer Sections - Titles Title font=arial bold "Table 1. Baseline Table: Sex, Race^{super a} Page ^{pageof} "; Font: font= ; Height: height=8pt; Justify: j= ; Superscript: ^{super &text}; Subscript: ^{sub &text}; Page X of Y: ^{pageof}; (V 9.0) Face Weight Style

38 38 Customize RTF File: Header/Footer Sections - Footnotes  Place font attributes before the text to apply  Syntax is same as SAS Procedures: PRINT, REPORT, and TABULATE  Remember to turn off style just like like turning off ODS

39 39 Example 6. Customize RTF File: Header/Footer Sections - Footnotes Footnote1 ”^S={font_face=arial font_style=italic} ^{super a}Race: Non-White consists of Black, Hispanic, and Native American^S={} ”; Footnote2 ”^S={font_face=arial font_style=italic}Program: /stat/druga/program1.sas ^S={} ” ; Font: “^S={font_face=arial}&text ^S={}”; “^S={font_weight=bold}&text ^S={}”; “^S={font_style=italic}&text ^S={}”; Face Weight Style

40 40 Applying Style Syntax in Proc Tabulate PROC TABULATE style=[]; /* Style for all data cells */ class /style=[]; /* Style for column and row header */ var / style=[]; /* Style for analysis variable heading */ table style=[] /* Style for entire table */ / box=[style=[]] ; /* Style for box label */ run;

41 41 Example 6. Customize RTF File: Using PROC TABULATE %let mystyle =%str(font_face="arial" font_weight=bold); (PROC FORMAT; value gender, race, pctpct; quit;) PROC TABULATE data=demog missing formchar=' -----------' style=[font_face=" courier"]; class gender race drug/style=[&mystyle]; format gender gender. race race.; table (gender race), drug=' '* (n='N'*f=7. pctn =' %' *f=pctpct. ) / box=[label='Baseline ' style=[&mystyle] ] rts=43; run;

42 42 Example 6. Summary Table : Output Using PROC TABULATE Arial, Bold Courier RTF

43 43 Example 7. Customize RTF File: Using PROC TABULATE OPTIONS ORIENTATION=LANDSCAPE nodate center; %let mystyle =%str(font_face="arial" font_weight=bold); PROC TABULATE data=demog missing formchar=' -----------' style=[font_face=" courier"]; class gender race drug/style=[&mystyle]; classlev gender race drug/style=[&mystyle]; format gender gender. race race.; keyword n pctn/style=[&mystyle]; table (gender race), drug=' '* (n='N'*f=7. pctn =' %' *f=pctpct. ) / box=[label='Baseline ' style=[&mystyle] ] rts=43; run;

44 44 Example 7. Summary Table : Output Using PROC TABULATE w/ CLASSLEV and KEYWORD Arial, Bold RTF

45 45 Customize RTF File: Using PROC PRINT PROC PRINT style() = [] (header, data, obs, obshead, table) /* all headers, data, obs column, obs column header, data table */ var / style() = []; (data, header) /* separate var statements */ id / style() = []; (data, header) sum / style() = []; (data, header, total) run;

46 46 Example 8a. Customize RTF File: Using PROC PRINT ODS RTF FILE = 'C:\how\gupta\table3.rtf' STYLE = MINIMAL BODYTITLE; PROC PRINT data=demog (obs=5) noobs style(header) = [font_face="arial" font_weight=bold] style(data)= [font_face="arial"]; var patient drug gender race age height weight; fomat gender gender. race race.; run; ODS RTF Close;

47 47 Example 8a. Customize RTF File: Using PROC PRINT Arial, Bold Arial RTF

48 48 Example 8b. Table with 2 Columns ODS RTF FILE = 'C:\how\gupta\table3.rtf' STYLE = MINIMAL COLUMNS=2; PROC PRINT data=demog style(header) = [font_face="arial" font_weight=bold] style(data)= [font_face="arial"]; var patient drug gender race age height weight; fomat gender gender. race race.; run; ODS RTF Close;

49 49 Example 8b. Table with 2 Columns RTF

50 50 Summary: Where to Go From Here  Programmer, Statistician, Manager  Power & Flexibility  Customizing Output  Creating Excel Files  RTF-control words  Applying Style Syntax in Proc Tabulate and Proc Print

51 51 SAS® ODS Technology for Today’s Decision Makers ODS RESOURCES  The Complete Guide to the SAS Output Delivery System Version 8  http://www.sas.com/rnd/base/index-ods-resources.html  Quick Results with the Output Delivery System  Output Delivery System: The Basics  Chevell Parker, Generating Custom Excel Spreadsheets Using ODS

52 52 SAS® ODS Technology for Today’s Decision Makers Sunil.Gupta@Quintiles.com Quintiles

53 53 SAS ® ODS Technology for Today’s Decision Makers Sunil Gupta Quintiles


Download ppt "1 SAS ® ODS Technology for Today’s Decision Makers Sunil Gupta Quintiles."

Similar presentations


Ads by Google