SAS Programming 1: Essentials - Lesson 1 PDF

Summary

This document is a lesson plan or presentation for a SAS Programming course. It covers introductory concepts such as the SAS Programming Process, SAS Programming Tools, and SAS Syntax. The presentation also gives a brief overview of the SAS language and how it can be used to process international storm data.

Full Transcript

Lesson 1: Essentials 1.1 The SAS Programming Process 1.2 Using SAS Programming Tools 1.3 Understanding SAS Syntax Copyright © SAS Institute Inc. All rights res er ved. Lesson 1: Essentials 1.1 The SAS Programming Process 1.2 Using SAS Programming Tools 1.3...

Lesson 1: Essentials 1.1 The SAS Programming Process 1.2 Using SAS Programming Tools 1.3 Understanding SAS Syntax Copyright © SAS Institute Inc. All rights res er ved. Lesson 1: Essentials 1.1 The SAS Programming Process 1.2 Using SAS Programming Tools 1.3 Understanding SAS Syntax Copyright © SAS Institute Inc. All rights res er ved. SAS Programming Language 3 Copyright © SAS Institute Inc. All rights res er ved. SAS Programming Process Analyze and Access Explore Prepare Export report on data data data results data 4 Copyright © SAS Institute Inc. All rights res er ved. SAS Programming Process Analyze and Access Explore Export Prepare data report on data data results data international storm data 5 Copyright © SAS Institute Inc. All rights res er ved. SAS Programming Process Analyze and Access Explore Export Prepare data report on data data results data 6 Copyright © SAS Institute Inc. All rights res er ved. SAS Programming Process This demonstration examines the international storm data that is used in course demonstrations. Copyright © SAS Institute Inc. All rights res er ved. p101d01 Discussion Which steps of the programming process are most challenging or critical in your work? Copyright © SAS Institute Inc. All rights res er ved. Data Used in This Course US National class Park data cars international storm and weather data shoes Europe tourism and trade data 9 Copyright © SAS Institute Inc. All rights res er ved. Practicing in This Course Demonstration Performed by your instructor as an example for you to observe Activity Short practice opportunities for you to perform in SAS, either independently or with the guidance of your instructor Practice Extended practice opportunities for you to work on independently Case Study A comprehensive practice opportunity at the end of the class 10 Copyright © SAS Institute Inc. All rights res er ved. Choosing a Practice Level Level 1 Solve basic problems with step-by-step guidance Level 2 Solve intermediate problems with defined goals Challenge Solve complex problems independently Choose one with SAS Help and documentation practice to do in resources class based on your interest and skill level. 11 Copyright © SAS Institute Inc. All rights res er ved. Lesson 1: Essentials 1.1 The SAS Programming Process 1.2 Using SAS Programming Tools 1.3 Understanding SAS Syntax Copyright © SAS Institute Inc. All rights res er ved. SAS Programming Interfaces SAS Studio SAS Enterprise Guide All these interfaces have the basic tools that you need for programming. SAS windowing environment 13 Copyright © SAS Institute Inc. All rights res er ved. SAS Programming Interfaces write view and 1 data myclass; view 2 set sashelp.class; messages submit 3 run; results from SAS code NOTE: There were 19 observations read from the data set SASHELP.CLASS. data myclass; NOTE: The data set WORK.MYCLASS has 19 set sashelp.class; observations and 5 variables. run; NOTE: DATA statement used: real time 0.01 seconds proc print data=myclass; cpu time 0.00 seconds run; 4 5 proc print data=myclass; NOTE: Writing HTML Body file: sashtml.htm 6 run; NOTE: There were 19 observations read from the data set WORK.MYCLASS. Editor Log Results and Output Data 14 Copyright © SAS Institute Inc. All rights res er ved. Submitting a SAS Program in SAS Enterprise Guide and SAS Studio These two demonstrations illustrate writing and submitting a simple SAS program and examining the log and results. The demos also show how to open and run an existing SAS program. Copyright © SAS Institute Inc. All rights res er ved. 1.01 Multiple Answer Question Which SAS interface will you use in class? a. SAS Enterprise Guide b. SAS Studio 16 Copyright © SAS Institute Inc. All rights res er ved. Practice This practice reinforces the concepts discussed previously. Copyright © SAS Institute Inc. All rights res er ved. Accessing the Course Files course files activities Make a note of data the location of your course files demos folder. practices output 18 Copyright © SAS Institute Inc. All rights res er ved. Accessing the Course Files Programs in the activities, demos, course and practices files folders follow this activities naming convention. data demos practices p104d01.sas Programming 1, Lesson 4, demo 1 output 19 Copyright © SAS Institute Inc. All rights res er ved. Creating the Course Data course files activities data cre8data.sas demos practices output 20 Copyright © SAS Institute Inc. All rights res er ved. 1.02 Activity (Required) 1. SAS Studio: In the Navigation pane, expand Files and Folders and then navigate to the course files folder. SAS Enterprise Guide: In the Servers list, expand Servers Local Files, and then navigate to the course files folder. 2. Double-click the cre8data.sas file to open the program. 3. Find the %LET statement. As directed by your instructor, provide the path to your course files. 4. Run the program and verify that a report that lists 22 tables is created. 21 Copyright © SAS Institute Inc. All rights res er ved. 1.02 Activity – Correct Answer Confirm that 22 SAS tables were created. 22 Copyright © SAS Institute Inc. All rights res er ved. Lesson 1: Essentials 1.1 The SAS Programming Process 1.2 Using SAS Programming Tools 1.3 Understanding SAS Syntax Copyright © SAS Institute Inc. All rights res er ved. SAS Program Structure step data myclass; set sashelp.class; heightcm=height*2.54; step run; proc print data=myclass; A SAS program step run; consists of a sequence of steps. proc means data=myclass;... var age heightcm; run; SAS program 24 Copyright © SAS Institute Inc. All rights res er ved. SAS Program Structure DATA step data myclass; set sashelp.class; heightcm=height*2.54; run; proc print data=myclass; A program can be PROC step run; any combination of DATA and PROC proc means data=myclass; (procedure) steps var age heightcm; run; 25 Copyright © SAS Institute Inc. All rights res er ved. SAS Program Structure DATA step data myclass; set sashelp.class; heightcm=height*2.54; run; proc print data=myclass; DATA steps run; typically read, process, or create proc means data=myclass; data. var age heightcm; run; 26 Copyright © SAS Institute Inc. All rights res er ved. SAS Program Structure data myclass; set sashelp.class; heightcm=height*2.54; run; proc print data=myclass; PROC steps typically report, PROC step run; manage, or proc means data=myclass; analyze data. var age heightcm; run; 27 Copyright © SAS Institute Inc. All rights res er ved. SAS Program Structure Steps begin with either DATA or PROC. data myclass; set sashelp.class; heightcm=height*2.54; run; proc print data=myclass; run; This program has three steps. Steps end with RUN. proc means data=myclass; Some PROCs end with var age heightcm; run; QUIT. 28 Copyright © SAS Institute Inc. All rights res er ved. SAS Program Structure step data myclass; set sashelp.class; statement; heightcm=height*2.54; statement; run; statement; proc print data=myclass; A step is a run; sequence of SAS step statements. proc means data=myclass; var age heightcm; step run; SAS program 29 Copyright © SAS Institute Inc. All rights res er ved. SAS Statement Syntax data myclass; set sashelp.class; heightcm=height*2.54; run; Most statements proc print data=myclass; run; begin with a keyword, and all proc means data=myclass; statements end with var age heightcm; a semicolon. run; 30 Copyright © SAS Institute Inc. All rights res er ved. Global Statements TITLE... ; OPTIONS... ; Global statements are typically outside of LIBNAME... ; steps and do not need a RUN statement. 31 Copyright © SAS Institute Inc. All rights res er ved. 1.03 Activity Open p101a03.sas from the activities folder and perform the following tasks: 1. View the code. How many steps are in the program? 2. How many statements are in the PROC PRINT step? 3. How many global statements are in the program? 4. Run the program and view the log. 5. How many observations were read by the PROC PRINT step? 32 Copyright © SAS Institute Inc. All rights res er ved. 1.03 Activity – Correct Answer Open p101a03.sas from the activities folder and perform the following tasks: 1. View the code. How many steps are in the program? There are three steps: one DATA step and two PROC steps. 2. How many statements are in the PROC PRINT step? four statements 3. How many global statements are in the program? three TITLE statements 4. Run the program and view the log. 5. How many observations were read by the PROC PRINT step? 11 observations 33 Copyright © SAS Institute Inc. All rights res er ved. SAS Program Syntax: Format data myclass;set sashelp.class;run; These are proc print data=myclass;run; the same to SAS. data myclass; set sashelp.class; run; Formatting makes your code easier proc print data=myclass; to read and run; understand. 34 Copyright © SAS Institute Inc. All rights res er ved. SAS Program Syntax: Case data under13; set sashelp.class; where AGE

Use Quizgecko on...
Browser
Browser