This privtae GitHub repository contains sample SAS programs that are used by the instructor to introduce SAS programming to students of STAT 4197/6197 at George Washington University. These programs center around topics that include key SAS language concepts as well as a wide variety applications of Base SAS (DATA step, SAS procedures, ODS, DATA step debugger, and macro facility), SQL, and SAS/IML. In addition, some applications of the SASPy package using selected features of the Python language in JupyterLab platform are also introduced.
Stored in different weekly folders, the sample programs will supplement weekly class handouts that are posted to GW Blackboard as well as here. Students are encouraged to use these programs as practice exercises to enhance their comprehension of the materials being discussed in class. The programs were written by the course instructor or adapted from various sources including SAS® Documentation, SUGI/SGF papers, Blogs, SAS-L, and SAS Support Communities (communities.sas.com). Please let the instructor know of any errors if you have found in the materials posted here. Don't circulate the materials.
For a high-level overview, topics covered in the course are listed under different sections (1 through 5) below. There are some additional advanced topics, which are included in sections 6 and 7; these topics will not be covered in this course.
1. SAS Programming Language Concepts (Here)
- SAS language elements (e.g., SAS statements, expressions, options, formats, and functions)
- Rules for naming variables
- Data types
- SAS statement types
- System options
- Missing values
- Ways to run SAS
- (When Using SAS 9.4 - Licensed)
- Windowing Environment (by default)
- Enterprise Guide
- SAS Studio
- JupyterLab
- (When Using SAS University Edition 9.4 - Free software)
- SAS Studio
- JupyterLab
- (When Using SAS 9.4 - Licensed)
- SAS files
- SAS data sets (2 types: SAS Data Files, and SAS Views)
- SAS catalog
- External files
- SAS libraries
(e.g., INPUT and INFILE (and/or DATALINES), SET, MERGE, and UPDATE Statements)
- Overview of DATA Step Processing
- Processing a DATA Step: A Walk-through
- Reading raw standard and nonstandard data into SAS
- Reading data in Excel format into SAS
- Creating temporary and permanent SAS data sets.
- Exporting SAS data sets into raw data files (Different PUT styles)
- Controlling observations and variables in a SAS data set
- Conditionally executing SAS statements
- Using assignment statements in the DATA step
- Accumulating sub-totals and totals using DATA step statements
- Using SAS functions to manipulate numeric and character data
- Using SAS functions to convert character data to numeric and vice versa
- Processing data using
ARRAYSandDO LOOPS - Combining data vertically and horzintally
- Aggregating/summarizing data
-
Utility procedures (e.g.,
PROC APPEND,PROC DATASETS,PROC FORMAT,PROC SORT,PROC SQL,PROC TRANSPOSE,PROC SURVEYSELECT) -
Getting information about SAS data sets (
PROC CONTENTS) -
Performining pre-analysis tasks
-
Statistical-Esque Procedures (e.g.,
PROC FREQ,PROC MEANS,PROC UNIVARIATE,PROC SUMMARY,PROC SQL,PROC REPORT,PROC TABULATE,PROC SURVEYMEANS,PROC SURVEYFREQ)-
Obtaining counts and percentages, and performing statistical tests
-
Calculating statistics (e.g., N, sum, mean, minimum, maximum, standard error, etc.)
-
-
Reporting Procedures for creating detailed and summary reports (e.g., PROC PRINT, PROC REPORT, PROC TABULATE)
- Identifying selected objects generated by a SAS procedure
- Storing SAS-procedure-generated selected object(s) in a SAS data set
- Sending the output generated by a SAS procedure to a specific destination
- Delivering output in a variety of easy-to-access procedure output files
- Symbolic substitution within SAS code
- Automated production of SAS code
- Conditional construction of SAS code
- Dynamic generation of SAS code
- Read data from SAS tables
- Add/modify/drop columns in SAS tables
- Sort/filter rows in SAS tables
- Create tables/views
- Join tables/views
- Create reports
- Create macro variables
- high-level, matrix-vector computations
- data analysis
- data simulation, statistical simulation, and bootstrap computations
- data tables (nonmatrix data structures)
- R within PROC IML
- Enabling communication between Jupyter and SAS when using the SAS Kernel
- Running Python code using commonly used IDE other than Jupyter Notebook
- Loading SAS data sets into Python-Pandas DataFrame objects
- Converting Python-Pandas DataFrame objects into SAS data sets
- Using Python convenience methods on SAS data sets
- Imitating the SAS macro facility
- Generating SAS code from Python code
- SAS/STAT
- DATA Step Component Objects
- Object-Oriented DS2 ("DATA Step 2") within PROC DS2
- FCMP Procedure
- Graph Template Language (GLT) within PROC SGRENDER and PROC TEMPLATE
- C/C++ within PROC PROTO
- Groovy within PROC GROOVY
- Java and other Languages via DATA Step Java Objects
- Lua within PROC LUA
- SAS Hadoop
- Perl-like regular expressions and call routines
- Data Management: Self-Service Data Preparation on SAS Viya
- Programming: Programming for SAS Viya
- Cloud Analytic Services Language (CASL) - [Read this artcle - What ia CASL?] (https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2019/3040-2019.pdf)
- Visualization: SAS Visual Analytics 1 for SAS Viya - Basics
- Analytics: SAS Visual Analytics on SAS Viya: Interatcive Model Building
- Analytics: SAS Visual Data Mining and Machine Learning on SAS Viya: Interactive Machine Learning
- Analytics: Supervised Machine Learning Procedures Using SAS Viya in SAS Studio
- Open Source: SAS Viya and Open Source Integration with R and Python
How to find your SAS version and components list
proc product_status; run;
proc setinit; run;