The knoweldge is priceless and thus i provide a basic document introducing SAS for free
Just enjoy it!
Author: Neil Spencer
Table of Contents
Chapter 1
Introducing SAS ........................................................ 1
1.1 Operating SAS ........................................................................ 2
1.1.1 Writing and Submitting a SAS Program .................. 3
1.1.2 SAS Log .................................................................... 3
1.1.3 SAS Output................................................................ 3
1.2 Operating SAS with Microsoft Windows............................... 3
1.2.1 Other Windows ............................................................4
1.2.2 Clearing Text from Windows .................................... 5
Chapter 2
Reading Data into SAS ............................................. 7
2.1 What is Plain Text?................................................................. 7
2.2 Tumour Necrosis Factor (TNF) Data ..................................... 7
2.3 Giving Labels to Variables.................................................... 15
2.4 Category Labels .....................................................................16
2.5 Using Simple Arithmetic to Create a
New Variable ......................................................................... 20
2.6 PROC IMPORT .................................................................... 23
2.6.1 Delimited Files ........................................................ 23
2.6.2 Spreadsheet Files ..................................................... 26
2.6.3 Database Tles ........................................................... 27
2.7 Reading Dates and Times ..................................................... 29
2.8 Tasks...................................................................................... 33
Chapter 3
Saving and Output of SAS Datasets ....................... 35
3.1 Permanent Datasets............................................................... 35
3.2 Data Manipulation, Permanent Datasets, and
the SET Statement .................................................................38
3.3 PROC REPORT .................................................................... 40
3.4 PUT ........................................................................................41
3.5 PROC EXPORT.................................................................... 42
3.5.1 Delimited Files ........................................................ 43
3.5.2 Spreadsheet Files ..................................................... 44
3.5.3 Database Files.......................................................... 44
3.6 Tasks...................................................................................... 45
Chapter 4
Manipulating Datasets ............................................. 47
4.1 Merging Datasets .................................................................. 47
4.2 Concatenating Datasets......................................................... 51
4.3 Merging and Concatenating in One Program ........................56
4.4 Further Manipulation of Datasets......................................... 63
4.5 Tasks...................................................................................... 68
Chapter 5
Restructuring Datasets ............................................. 71
5.1 Splitting One Row of Data into Several Rows .................... 71
5.2 Combining Several Rows of Data into
One Row ............................................................................... 76
5.3 Tasks...................................................................................... 82
Chapter 6
Summarising Data ................................................... 85
6.1 PROC MEANS ..................................................................... 85
6.2 PROC UNIVARIATE..............................................................87
6.3 PROC FREQ......................................................................... 91
6.4 Tasks...................................................................................... 93
Chapter 7
Tabulating Data........................................................ 95
7.1 PROC MEANS ..................................................................... 95
7.2 PROC TABULATE for Summarising Data........................ 100
7.3 PROC TABULATE for Cross-Tabulations ......................... 103
7.4 Tasks.................................................................................... 104
Chapter 8
Formatting and Saving SAS Output...................... 107
8.1 Output Delivery System...................................................... 107
8.1.1 Listing .................................................................... 108
8.1.2 Printer .....................................................................108
8.1.3 HTML.................................................................... 108
8.1.4 RTF ........................................................................ 109
8.1.5 PDF ........................................................................ 110
8.1.6 OUTPUT................................................................ 110
8.1.7 ODS TRACE ......................................................... 110
8.1.8 PROC TEMPLATE................................................ 111
8.1.9 Example Using ODS Destinations,TRACE and SELECT............................................ 111
8.1.10 Names Required ......................................................116
8.1.11 Printing the “Quantilesoutput” Datas to the HTML Destination ..................................................120
8.2 Saving SAS Output as a SAS Dataset ............................... 122
8.3 Tasks.................................................................................... 124
Chapter 9
Graphics in SAS .................................................... 125
9.1 Los Angeles Depression Data............................................. 125
9.2 Histogram of CESD Score.................................................. 125
9.2.1 Basic Histogram .................................................... 125
9.2.2 Labelling of End Points for Bars ...........................126
9.2.3 DeTning the Bars ....................................................127
9.2.4 Counts and Labels on the Vertical Axis................ 129
9.2.5 Adding a Normal Curve ........................................ 130
9.3 Bar Chart of Marital Status ................................................ 131
9.3.1 Basic Bar Chart ..................................................... 131
9.3.2 Three-Dimensional Bar Chart ............................... 133
9.3.3 Bar Chart with Formatted Axis ............................. 134
9.3.4 Bar Chart with Formatted Axis and
Labelled Bars......................................................... 136
9.3.5 Bar Chart with Summaries by Another
Variable .................................................................. 138
9.4 Bar Chart of Religion Grouped by
Marital Status .......................................................................138
9.4.1 Horizontal Bar Chart ............................................. 139
9.4.2 Stacked Bar Chart.................................................. 140
9.5 Pie Chart of Marital Status................................................. 142
9.5.1 Basic Pie Chart ........................................................142
9.5.2 Pie Chart with Formatting..................................... 143
9.5.3 Pie Chart with Formatting and an
Exploded Segment ................................................. 145
9.6 Plot of CESD Score against Age........................................ 146
9.6.1 Basic Scatter Plot................................................... 147
9.6.2 Scatter Plot with Formatting ................................. 148
9.7 Tasks.................................................................................... 149
Chapter 10
An Introduction to Macros .................................... 151
10.1 Example of a Macro to Print Datasets ............................... 151
10.2 Example of a Macro to Create and Format
an Histogram....................................................................... 154
10.3 Tasks.................................................................................... 156
Appendix A
Nurses’ Glove Use Data ........................................ 161
Appendix B
Los Angeles Depression Data ............................... 165
Appendix C
Solution Programs for Tasks ................................. 173