SAS - PowerPoint PPT Presentation

About This Presentation
Title:

SAS

Description:

(Defines the output file type: HTML, RTF, PDF, LISTING, OUTPUT) Creating Output Objects ... var / style=[]; /* Style for analysis variable heading ... – PowerPoint PPT presentation

Number of Views:237
Avg rating:3.0/5.0
Slides: 54
Provided by: Sunil87
Category:
Tags: sas | var

less

Transcript and Presenter's Notes

Title: SAS


1
  • SAS ODS Technology for Todays Decision Makers
  • Sunil Gupta
  • Quintiles

2
SAS Users
  • Manager Excel file, HTML drill down files

3
Agenda
  • Whats 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
Whats 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
Defining Output Destinations
  •  
  •   
  • ODS
  •  
  •  

  •  

6
Create Demog Data Set
  • Patient, Sex, Height, Weight, Age, Race, Drug
  • (n25 records)

7
Creating Output Files Report Files
  • ODS ltFile Typegt File
  • SAS Procedure(s)
  • ODS ltFile Typegt CLOSE
  • Where File Type HTML, RTF, Listing, PDF, ..
  • Keep consistent filename types .html, rtf, lst,
    pdf, ..

Results of one or more SAS Procedures
8
Example 1a. Create Excel File demog.xls
  • lt ODS Statement with minimal stylegt
  • PROC UNIVARIATE DATADEMOG
  • VAR WEIGHT
  • RUN
  • lt ODS Statement gt

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

Excel
10
Example 1a. Create Excel File demog.xls

Each result item is in its own cell!
11
Example 1b. Create Demog_Style HTML File with
Style
  • lt ODS HTML Statement with barrettsblue style gt
  • PROC UNIVARIATE DATADEMOG
  • VAR WEIGHT
  • RUN
  • lt ODS HTML Statement gt

12
Example 1b. Create HTML File with Style
  • ODS HTML FILE 'c\how\gupta\demog_style.html'
  • STYLE barrettsblue
  • PROC UNIVARIATE DATADEMOG
  • VAR WEIGHT
  • RUN
  • ODS HTML CLOSE

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

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
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
Example 2a. Create Output Data Set Measure from
Basic Measures Info
  • ODS OUTPUT ltobject namegt ltdata set namegt
  • PROC UNIVARIATE DATADEMOG
  • VAR WEIGHT
  • RUN
  • ODS OUTPUT CLOSE

17
Creating Output Objects

O U T P U T O B J E C T S
18
Identifying Output Objects List File
ODS TRACE ON / LABEL LISTING (One of Several
Output Objects Created)
  • Output Added

Name BasicMeasures Label
Basic Measures of Location and Variability Templat
e 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
Example 2a. Create Output Data Set Measure from
Basic Measures Info
  • ODS TRACE ON / LABEL LISTING
  • ODS OUTPUT ltobject namegt ltdata set namegt
  • PROC UNIVARIATE DATADEMOG
  • VAR WEIGHT
  • RUN
  • ODS OUTPUT CLOSE

20
Example 2a. Create Output Data Set Measure from
Basic Measures Info
  • ODS OUTPUT BASICMEASURES MEASURE
  • PROC UNIVARIATE DATADEMOG
  • VAR WEIGHT
  • RUN
  • ODS OUTPUT CLOSE
  • Proc print run
  • Note OUTPUT OUT statement in procedures are
    still valid!

(Data set Name)
(Object Name)
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
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
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
DATADEMOG VAR WEIGHT HEIGHT RUN PROC
UNIVARIATE DATADEMOG VAR AGE RUN ODS OUTPUT
CLOSE PUT Macro variable MEASURE_DSN
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
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
dataallmeans nowd columns varname locvalue
define varname/ Variable define locvalue /
Mean style background
ltformatgt run ods html close
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
dataallmeans nowd columns varname locvalue
define varname/ Variable define locvalue /
Mean style background
traffic. run ods html close
27
Using Traffic Lighting Conditions to identify
significance
GreaterThan 100
Make results visually informative.
28
Example 4. Create Plots and Tables as Plots.rtf
File
  • lt ODS Statement to create rtf file gt
  • proc univariate data demog lt plots gt
  • var weight
  • lt histogram / cfillcyangt
  • run
  • ods rtf close

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 / cfillcyan
  • run
  • ods rtf close

Plots.rtf
You can have it all - tables and plots in one
file!
30
Example 4. Creating Plots and Tables as RTF File
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
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
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 datartfcontrol
  • run ods rtf close

Be careful to match all quotes
34
Example 5. Custom RTF File RTF Control Words -
Title and Data Step
RTF
Look what SAS can do - it really works!
35
Example 6. Summary Table Using In-line Formatting
Text in RTF files
  • OPTIONS ORIENTATIONPORTRAIT 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
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
Example 6. Customize RTF File Header/Footer
Sections - Titles
  • Title fontarial bold
  • "Table 1. Baseline Table Sex, Racesuper a
    Page pageof "
  • Font fontltcouriertimesarialhelve
    ticagt
  • ltboldmedianlightgt
  • ltitalicromanslantgt
  • Height height8pt
  • Justify jltleftrightcentergt
  • Superscript super text
    Subscript sub text
  • Page X of Y pageof (V 9.0)

Face
Weight
Style
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
Example 6. Customize RTF File Header/Footer
Sections - Footnotes
  • Footnote1 Sfont_facearial font_styleitalic
    super aRace Non-White consists of Black,
    Hispanic, and Native AmericanS
  • Footnote2 Sfont_facearial font_styleitalicP
    rogram /stat/druga/program1.sas S
  • Font
  • Sfont_facearialtext S
  • Sfont_weightboldtext S
  • Sfont_styleitalictext S

Face
Weight
Style
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 /
  • / boxstyle
    / Style for box label /
  • run

41
Example 6. Customize RTF File Using PROC
TABULATE
  • let mystyle str(font_face"arial"
    font_weightbold)
  • (PROC FORMAT value gender, race, pctpct quit)
  • PROC TABULATE datademog missing formchar'
    -----------'
  • stylefont_face" courier"
  • class gender race drug/stylemystyle
  • format gender gender. race race.
  • table (gender race), drug' '
  • (n'N'f7. pctnltgender racegt' '
    fpctpct. )
  • / boxlabel'Baseline '
  • stylemystyle rts43
  • run

42
Example 6. Summary Table Output Using PROC
TABULATE
RTF
Arial, Bold
Courier
43
Example 7. Customize RTF File Using PROC
TABULATE
  • OPTIONS ORIENTATIONLANDSCAPE nodate center
  • let mystyle str(font_face"arial"
    font_weightbold)
  • PROC TABULATE datademog missing formchar'
    -----------'
  • stylefont_face" courier"
  • class gender race drug/stylemystyle
  • classlev gender race drug/stylemystyle
  • format gender gender. race race.
  • keyword n pctn/stylemystyle
  • table (gender race), drug' '
  • (n'N'f7. pctnltgender racegt' '
    fpctpct. )
  • / boxlabel'Baseline '
  • stylemystyle rts43
  • run

44
Example 7. Summary Table Output Using PROC
TABULATE w/ CLASSLEV and KEYWORD
RTF
Arial, Bold
Arial, Bold
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
Example 8a. Customize RTF File Using PROC PRINT
  • ODS RTF FILE 'C\how\gupta\table3.rtf' STYLE
    MINIMAL BODYTITLE
  • PROC PRINT datademog (obs5) noobs
  • style(header) font_face"arial"
    font_weightbold
  • style(data) font_face"arial"
  • var patient drug gender race age height weight
  • fomat gender gender. race race.
  • run
  • ODS RTF Close

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

Arial
48
Example 8b. Table with 2 Columns
  • ODS RTF FILE 'C\how\gupta\table3.rtf' STYLE
    MINIMAL COLUMNS2
  • PROC PRINT datademog
  • style(header) font_face"arial"
    font_weightbold
  • style(data) font_face"arial"
  • var patient drug gender race age height weight
  • fomat gender gender. race race.
  • run
  • ODS RTF Close

49
Example 8b. Table with 2 Columns
RTF

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
SAS ODS Technology for Todays Decision Makers
  • ODS RESOURCES
  • The Complete Guide to the SAS Output Delivery
    System Version 8
  • http//www.sas.com/rnd/base/index-ods-resources.ht
    ml
  • Quick Results with the Output Delivery System
  • Output Delivery System The Basics
  • Chevell Parker, Generating Custom Excel
    Spreadsheets Using ODS

52
SAS ODS Technology for Todays Decision Makers
  • Sunil.Gupta_at_Quintiles.com
  • Quintiles

ODS
53
  • SAS ODS Technology for Todays Decision Makers
  • Sunil Gupta
  • Quintiles
Write a Comment
User Comments (0)
About PowerShow.com