SlideShare a Scribd company logo
1 of 147
Chapter 2 Getting Started with the SAS ®  System
Section 2.1 Introduction to SAS Programs
[object Object],[object Object],Objectives
SAS Vocabulary ,[object Object],[object Object],[object Object]
Turning Data into information DATA Step Data Output SAS Data Set PROC Step LastName  FirstName  Age TORRES  JAN 23 LANGKAMM  SARAH 46 SMITH  MICHAEL 71 WAGSCHAL  NADJA 37 TOERMOEN  JOCHEN 16
SAS Programs ,[object Object],DATA Step Output Raw Data SAS Data Set SAS Data Set 129986542,Fred,Barnes,54,654543681,Alicia,Burnett,23,241453384,Connor,Coats PROC Step LastName  FirstName  Age TORRES  JAN 23 LANGKAMM  SARAH 46 SMITH  MICHAEL 71 WAGSCHAL  NADJA 37 TOERMOEN  JOCHEN 16 LastName  FirstName  Age TORRES  JAN 23 LANGKAMM  SARAH 46 SMITH  MICHAEL 71 WAGSCHAL  NADJA 37 TOERMOEN  JOCHEN 16 DATA steps  are typically used to create SAS data sets. PROC (procedure) steps  are used to process SAS data sets (generate reports and sort data).
data work.staff; infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff; run; proc means data=work.staff; class JobTitle; var Salary; run; DATA Step PROC Steps SAS Programs
SAS Programs ,[object Object],[object Object]
Step Boundaries ,[object Object],[object Object],[object Object],[object Object],[object Object],data work.staff; infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff; run; proc means data=work.staff; class JobTitle; var Salary; run; DATA Step PROC Steps
data  work.staff; infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc  print data=work.staff; proc  means data=work.staff; class JobTitle; var Salary; run; Step Boundaries
Running a SAS Program ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SAS Windowing Environment ,[object Object],[object Object]
Section 2.2 Running SAS Programs
[object Object],[object Object],[object Object],Objectives
SAS Vocabulary KEYS LOG Program Editor SAS log Enhanced Editor SUBMIT WED Editor window OUTPUT INCLUDE CLEAR LOG SAS Output
Submitting a SAS Program When you execute a SAS program, the output generated by SAS is divided into two major parts: contains reports generated by SAS procedures and DATA steps. SAS output contains information about the processing of the SAS program, including any warning and error messages. SAS log
SAS Log 1  data work.staff; 2  infile 'raw-data-file'; 3  input LastName $ 1-20 FirstName $ 21-30 4  JobTitle $ 36-43 Salary 54-59; 5  run; NOTE: The infile 'raw-data-file' is: File Name= 'raw-data-file', RECFM=V,LRECL=256 NOTE: 18 records were read from the infile 'raw-data-file'. The minimum record length was 59. The maximum record length was 59. NOTE: The data set WORK.STAFF has 18 observations and 4 variables. 6  proc print data=work.staff; 7  run; NOTE: There were 18 observations read from the dataset WORK.STAFF. 8  proc means data=work.staff; 9  class JobTitle; 10  var Salary; 11  run; NOTE: There were 18 observations read from the dataset WORK.STAFF.
PRINT Procedure Output The SAS System First Obs  LastName  Name  JobTitle  Salary 1  TORRES  JAN  Pilot  50000 2  LANGKAMM  SARAH  Mechanic  80000 3  SMITH  MICHAEL  Mechanic  40000 4  LEISTNER  COLIN  Mechanic  36000 5  WADE  KIRSTEN  Pilot  85000 6  TOMAS  HARALD  Pilot  105000 7  WAUGH  TIM  Pilot  70000 8  LEHMANN  DAGMAR  Mechanic  64000 9  TRETTHAHN  MICHAEL  Pilot  100000 10  TIETZ  OTTO  Pilot  45000 11  O'DONOGHUE  ART  Mechanic  52000 12  WALKER  THOMAS  Pilot  95000 13  NOROVIITA  JOACHIM  Mechanic  78000 14  OESTERBERG  ANJA  Mechanic  80000 15  LAUFFER  CRAIG  Mechanic  40000 16  TORR  JUGDISH  Pilot  45000 17  WAGSCHAL  NADJA  Pilot  77500 18  TOERMOEN  JOCHEN  Pilot  65000
MEANS Procedure Output The SAS System The MEANS Procedure Analysis Variable : Salary N JobTitle  Obs  N  Mean  Std Dev  Minimum ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Mechanic  8  8  58750.00  19151.65  36000.00 Pilot  10  10  73750.00  22523.14  45000.00 ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Analysis Variable : Salary N JobTitle  Obs  Maximum ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Mechanic  8  80000.00 Pilot  10  105000.00 ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
[object Object],Running a SAS Program
[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Invoking SAS
Command Box Output Window (behind) Current Working Directory Menus Toolbar Explorer Log Window Enhanced Editor
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],Demonstration – Running a SAS Program Remember
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
[object Object],[object Object],[object Object],Demonstration – Running a SAS Program
What Do You Do If… ,[object Object],[object Object],[object Object],[object Object]
What Do You Do If… ,[object Object],[object Object],[object Object],[object Object]
Program Editor versus Enhanced Editor Keeps code after a submit Code not kept after a submit Can have many windows open Can only have one window open Has a blue  +  added to the icons Title bar: Editor Title bar: Program Editor Coloring is different. Coloring is different. Enhanced Editor Program Editor
What Do You Do If… ,[object Object],[object Object],[object Object]
What Do You Do If… ,[object Object],[object Object],[object Object]
[object Object],Exercise
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Exercises
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Exercises
[object Object],[object Object],Exercises
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Exercises
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Exercises
Section 2.3 Mastering Fundamental Concepts
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Objectives
SAS Vocabulary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],Mastering Fundamental Concepts
SAS Data Set Terminology SAS documentation and text in the SAS windowing environment use the following terms interchangeably: SAS Data Set Table Variable Column Observation Row
SAS Data Sets ,[object Object],SAS  Data Set Descriptor Portion Data Portion
SAS Data Sets ,[object Object],[object Object]
[object Object],SAS Data Sets General data set information  * data set name  * data set label * date/time created  * storage information * number of observations Information for each variable * Name  * Type   * Length * Position * Format * Informat  * Label Descriptor Portion Data Portion
[object Object],[object Object],[object Object],[object Object],[object Object],Browsing the Descriptor Portion
[object Object],[object Object],Browsing the Descriptor Portion PROC CONTENTS  DATA= SAS-data-set ; RUN; proc contents data=sashelp.class; run;
Partial PROC CONTENTS Output The SAS System The CONTENTS Procedure Data Set Name  SASHELP.CLASS    Observations  19 Member Type  DATA    Variables  5 Engine  V9    Indexes  0 Created  Wednesday, May 12, 2004  Observation Length  40 10:53:55 PM Last Modified  Wednesday, May 12, 2004  Deleted Observations  0 10:53:55 PM Protection  Compressed  NO Data Set Type  Sorted  NO Alphabetic List of Variables and Attributes #  Variable  Type  Len 3  Age  Num  8 4  Height  Num  8 1  Name  Char  8 2  Sex  Char  1 5  Weight  Num  8
SAS Data Sets: Data Portion Numeric  values Variable names Variable values LastName  FirstName  JobTitle  Salary TORRES  JAN  Pilot  50000 LANGKAMM  SARAH  Mechanic  80000 SMITH  MICHAEL  Mechanic  40000 WAGSCHAL  NADJA  Pilot  77500 TOERMOEN  JOCHEN  Pilot  65000 The  data portion   of a SAS data set is a rectangular table of character and/or numeric data values. Variable names are part of the descriptor portion, not the data portion. Character values
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],SAS Variable Values continued...
SAS Variable Values ,[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],SAS Data Set and Variable Names
[object Object],Valid SAS Names  data5mon    data5mon    5monthsdata    five months data    data#5    fivemonthsdata    FiveMonthsData ...
[object Object],Valid SAS Names  data5mon    data5mon ...
[object Object],Valid SAS Names  data5mon ...
[object Object],Valid SAS Names  data5mon  data5mon    5monthsdata ...
[object Object],Valid SAS Names  data5mon  data5mon    5monthsdata ...
[object Object],Valid SAS Names  data5mon  data5mon    5monthsdata    data#5 ...
[object Object],Valid SAS Names  data5mon  data5mon    5monthsdata    data#5 ...
[object Object],Valid SAS Names  data5mon  data5mon    5monthsdata    data#5    five months data ...
[object Object],Valid SAS Names  data5mon  data5mon    5monthsdata    data#5    five months data ...
[object Object],Valid SAS Names  data5mon  data5mon    5monthsdata    five months data    data#5    fivemonthsdata ...
[object Object],Valid SAS Names  data5mon  data5mon    5monthsdata    five months data    data#5    fivemonthsdata ...
[object Object],Valid SAS Names  data5mon  data5mon    5monthsdata    five months data    data#5    fivemonthsdata    FiveMonthsData ...
[object Object],Valid SAS Names  data5mon  data5mon    5monthsdata    five months data    data#5    fivemonthsdata    FiveMonthsData
[object Object],Exercise
[object Object],[object Object],[object Object],Exercises
[object Object],[object Object],[object Object],Dates in SAS
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],SAS Dates
[object Object],[object Object],SAS Date Values 01JAN1959 01JAN1960 01JAN1961 store -365 0 366 display 01/01/1959 01/01/1960 01/01/1961
Missing Data Values LastName  FirstName  JobTitle  Salary TORRES  JAN  Pilot  50000 LANGKAMM  SARAH  Mechanic  80000 SMITH  MICHAEL  Mechanic  . WAGSCHAL  NADJA  Pilot  77500 TOERMOEN  JOCHEN  65000 A value must exist for every variable for each observation. Missing values are valid values. A numeric missing value is displayed as a  period . A character missing value is displayed as a  blank .
Browsing the Data Portion ,[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],Browsing the Data Portion PROC PRINT  DATA= SAS-data-set ;   RUN; proc print data=work.staff; run; PROC is the  keyword . PRINT is the  procedure name .
PROC PRINT Output The SAS System First Obs  LastName  Name  JobTitle  Salary 1  TORRES  JAN  Pilot  50000 2  LANGKAMM  SARAH  Mechanic  80000 3  SMITH  MICHAEL  Mechanic  40000 4  LEISTNER  COLIN  Mechanic  36000 5  WADE  KIRSTEN  Pilot  85000 6  TOMAS  HARALD  Pilot  105000 7  WAUGH  TIM  Pilot  70000 8  LEHMANN  DAGMAR  Mechanic  64000 9  TRETTHAHN  MICHAEL  Pilot  100000 10  TIETZ  OTTO  Pilot  45000 11  O'DONOGHUE  ART  Mechanic  52000 12  WALKER  THOMAS  Pilot  95000 13  NOROVIITA  JOACHIM  Mechanic  78000 14  OESTERBERG  ANJA  Mechanic  80000 15  LAUFFER  CRAIG  Mechanic  40000 16  TORR  JUGDISH  Pilot  45000 17  WAGSCHAL  NADJA  Pilot  77500 18  TOERMOEN  JOCHEN  Pilot  65000
[object Object],[object Object],[object Object],data  work.staff; infile  ' raw-data-file '; input  LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run ; proc  print data=work.staff; run ; proc  means data=work.staff; class  JobTitle; var  Salary; run ; SAS Syntax Rules continued...
SAS Syntax Rules ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],data work.staff;  infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc means data=work.staff;  class JobTitle;  var Salary;run;
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],SAS Syntax Rules data work . staff;  infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc means data=work.staff;  class JobTitle;  var Salary;run;
SAS Syntax Rules ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],data  work.staff;  infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc  means data=work.staff;  class JobTitle ;   var  Salary;run;
SAS Syntax Rules ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],data work.staff;  infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc means data=work.staff;  class JobTitle;  var Salary;run;
SAS Syntax Rules ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],data work.staff;  infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc means data=work.staff;  class JobTitle;  var Salary;run; ...
[object Object],[object Object],data work.staff; infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30  JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff; run; proc means data=work.staff; class JobTitle; var Salary; run; SAS Syntax Rules
[object Object],[object Object],[object Object],[object Object],/* Create work.staff data set */ data work.staff; infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; /* Produce listing report of work.staff */ proc print data=work.staff; run; SAS Comments
[object Object],[object Object],[object Object],[object Object],SAS Comments data work.staff; infile ' raw-data-file '; *input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run;
Shortcut to Comments ,[object Object],[object Object],[object Object]
[object Object],Exercise – Section 2.3
Section 2.4 Diagnosing and Correcting Syntax Errors
[object Object],[object Object],[object Object],[object Object],Objectives
SAS Vocabulary ,[object Object],[object Object],[object Object]
Syntax Errors ,[object Object],[object Object],[object Object],[object Object],daat work.staff; infile ‘emplist.dat’; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff  run; proc means data=work.staff average max; class JobTitle; var Salary; run; Average is not a valid option.
Syntax Errors ,[object Object],[object Object],[object Object],[object Object],proc means data=work.staff average max; class JobTitle; var Salary; run;
Syntax Errors ,[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Debugging a SAS Program
In this demonstration, you open a program that has errors and submit it.  Find the errors and correct them. Programs to open:  c02s4d1.sas c02s4d2.sas Demonstration – Debugging a SAS Program
[object Object],[object Object],Demonstration – Debugging a SAS Program
Submit a SAS Program with Errors   daat  work.staff; infile   'emplist.dat' ; input  LastName $  1 - 20  FirstName $  21 - 30 JobTitle $  36 - 43  Salary  54 - 59 ; run ; proc  print  data =work.staff run; proc  means  data =work.staff average  max ; class  JobTitle; var  Salary; run ; Demonstration – Debugging a SAS Program
The SAS log contains error messages and warnings.  1  daat  work.staff; ---- 14 WARNING 14-169: Assuming the symbol DATA was misspelled as daat.   2  infile ‘… emplist.dat '; 3  input LastName $ 1-20 FirstName $ 21-30 4  JobTitle $ 36-43 Salary 54-59; 5  run;   NOTE: The infile ‘… emplist.dat ' is: File Name=‘… emplist.dat ', RECFM=V,LRECL=256   NOTE: 18 records were read from the infile ‘… emplist.dat '. The minimum record length was 59. The maximum record length was 59. NOTE: The data set WORK.STAFF has 18 observations and 4 variables. Part 1 of 4 Demonstration – Debugging a SAS Program
The SAS log contains error messages and warnings.  6 7  proc print data=work.staff 8  run; --- 22 - 200 ERROR 22-322: Syntax error, expecting one of the following: ;, (, DATA, DOUBLE, HEADING, LABEL, N, NOOBS, OBS, ROUND, ROWS, SPLIT, STYLE, UNIFORM, WIDTH. ERROR 200-322: The symbol is not recognized and will be ignored. 9   NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE PRINT used (Total process time): real time  0.06 seconds cpu time  0.06 seconds  Part 2 of 4 Demonstration – Debugging a SAS Program
The SAS log contains error messages and warnings.  10  proc means data=work.staff  average max; ------- --- 22  202 ERROR 22-322: Syntax error , expecting one of the following: ;, (, ALPHA, CHARTYPE, CLASSDATA, CLM, COMPLETETYPES, CSS, CV, DATA, DESCEND, DESCENDING, DESCENDTYPES, EXCLNPWGT, EXCLNPWGTS, EXCLUSIVE, FW, IDMIN, KURTOSIS, LCLM, MAX, MAXDEC,  MEAN , MEDIAN, MIN, MISSING, N, NDEC, NMISS, NONOBS, NOPRINT, NOTHREADS, NOTRAP, NWAY,  ORDER, P1, P10, P25, P5, P50, P75, P90, P95, P99,  PCTLDEF, PRINT, PRINTALL, PRINTALLTYPES, PRINTIDS, PRINTIDVARS, PROBT, Q1, Q3, QMARKERS, QMETHOD, QNTLDEF, QRANGE, RANGE, SKEWNESS, STDDEV, STDERR, SUM, SUMSIZE, SUMWGT, T, THREADS, UCLM,  USS, VAR, VARDEF. ERROR 202-322: The option or parameter is not recognized and will be ignored. 11  class JobTitle; 12  var Salary; 13  run; Part 3 of 4 Demonstration – Debugging a SAS Program
The SAS log contains error messages and warnings.    NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE MEANS used (Total process time): real time  0.05 seconds cpu time  0.05 seconds Part 4 of 4 Demonstration – Debugging a SAS Program
[object Object],[object Object],[object Object],[object Object],Demonstration – Debugging a SAS Program
[object Object],[object Object],[object Object],continued... Demonstration – Debugging a SAS Program
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],continued... Demonstration – Debugging a SAS Program
data  work.staff; infile   'emplist.dat' ; input  LastName $  1 - 20  FirstName $  21 - 30 JobTitle $  36 - 43  Salary  54 - 59 ; run ; proc   print   data =work.staff; run ; proc   means   data =work.staff  mean   max ; class  JobTitle; var  Salary; run ; Demonstration – Debugging a SAS Program
[object Object],[object Object],[object Object],[object Object],Demonstration – Submitting Part  of the Code
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Demonstration – Submitting Part  of the Code
[object Object],[object Object],[object Object],Demonstration – Submitting Part  of the Code
[object Object],[object Object],[object Object],Demonstration – Solution
[object Object],[object Object],Demonstration – Solution
[object Object],[object Object],Demonstration – Debugging a SAS Program
Another Example ,[object Object],data  work.staff; infile   'emplist.dat; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff; run; proc means data=work.staff mean max; class JobTitle; var Salary; run;
Using Quotation Marks in SAS ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],=
Unbalanced Quot ation Marks ,[object Object],data  work.staff; infile   'c:asatamplist.dat; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff  run; proc means data=work.staff average max; class JobTitle; var Salary; run;
Unbalanced Quot ation Marks ,[object Object],[object Object],[object Object]
Fixing Quotation Errors ,[object Object],[object Object],[object Object],[object Object],[object Object]
Fixing Quotation Errors ,[object Object],[object Object],[object Object],[object Object],[object Object]
Programmatically   ,[object Object],[object Object]
Programmatically   ,[object Object],[object Object],[object Object],[object Object]
Programmatically  ,[object Object],[object Object],[object Object],[object Object]
Programmatically   ,[object Object],[object Object],[object Object]
Programmatically   ,[object Object],[object Object],[object Object],[object Object]
Programmatically  ,[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],Point-and-Click
Point-and-Click  ,[object Object]
Fixing the Program   ,[object Object],[object Object],[object Object]
Resubmitting the Program   27  data work.staff; 28  infile 'raw-data-file' ; 29  input LastName $ 1-20 FirstName $ 21-30 30  JobTitle $ 36-43 Salary 54-59; 31  run;   NOTE: 18 records were read from the infile 'raw-data-file'. The minimum record length was 59. The maximum record length was 59. NOTE: The data set WORK.STAFF has 18 observations and 4 variables. 32 33  proc print data=work.staff; 34  run;   NOTE: There were 18 observations read from the dataset WORK.STAFF. 35 36  proc means data=work.staff mean max; 37  class JobTitle; 38  var Salary; 39  run; NOTE: There were 18 observations read from the dataset WORK.STAFF.
Saving a SAS Program ,[object Object],[object Object],[object Object],[object Object],[object Object]
What Happens If …  ,[object Object],[object Object],[object Object]
What If You Need to Get the Code Back? ,[object Object],[object Object],[object Object],[object Object],LIFO L ast  I n  F irst  O ut
What If You Need to Get the Code Back? ,[object Object],[object Object],[object Object],[object Object],[object Object],Remember
[object Object],Recall a Submitted Program daat work.staff; infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff  run; proc means data=work.staff average max; class JobTitle; var Salary; run; data work.staff; infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff;  run; proc means data=work.staff mean max; class Jobtitle; var Salary; run; Submit Number 1 Submit Number 2
[object Object],Recall a Submitted Program Submit Number 1 Submit Number 2 Issue RECALL once. Submit Number 2 statements are recalled. data work.staff; infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff;  run; proc means data=work.staff mean max; class JobTitle; var Salary; run;
[object Object],Recall a Submitted Program Submit Number 1 Submit Number 2 Issue RECALL again. daat work.staff; infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff  run; proc means data=work.staff average max; class JobTitle; var Salary; run; data work.staff; infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff;  run; proc means data=work.staff mean max; class JobTitle; var Salary; run;
[object Object],Exercise – Section 2.4

More Related Content

Similar to Hechsp 001 Chapter 2

BAS 150 Lesson 3 Lecture
BAS 150 Lesson 3 LectureBAS 150 Lesson 3 Lecture
BAS 150 Lesson 3 LectureWake Tech BAS
 
Introduction To Sas
Introduction To SasIntroduction To Sas
Introduction To Sashalasti
 
Introduction to sas.pptx
Introduction to sas.pptxIntroduction to sas.pptx
Introduction to sas.pptxAvinabaHandson
 
Sap basis administration handbook
Sap basis administration handbookSap basis administration handbook
Sap basis administration handbookblackgoldboy
 
Basics Of SAS Programming Language
Basics Of SAS Programming LanguageBasics Of SAS Programming Language
Basics Of SAS Programming Languageguest2160992
 
SAS Mainframe -Program-Tips
SAS Mainframe -Program-TipsSAS Mainframe -Program-Tips
SAS Mainframe -Program-TipsSrinimf-Slides
 
Creating Reports in SAS Final
Creating Reports in SAS FinalCreating Reports in SAS Final
Creating Reports in SAS FinalRyan Davidson
 
InduSoft Web Studio Driver Overview – SITIA and ABCIP
InduSoft Web Studio Driver Overview – SITIA and ABCIPInduSoft Web Studio Driver Overview – SITIA and ABCIP
InduSoft Web Studio Driver Overview – SITIA and ABCIPAVEVA
 
SQL Performance Tuning and New Features in Oracle 19c
SQL Performance Tuning and New Features in Oracle 19cSQL Performance Tuning and New Features in Oracle 19c
SQL Performance Tuning and New Features in Oracle 19cRachelBarker26
 
Call Execute For Everyone
Call Execute For EveryoneCall Execute For Everyone
Call Execute For EveryoneDaniel Boisvert
 
R12 d49656 gc10-apps dba 22
R12 d49656 gc10-apps dba 22R12 d49656 gc10-apps dba 22
R12 d49656 gc10-apps dba 22zeesniper
 
Understanding SAS Data Step Processing
Understanding SAS Data Step ProcessingUnderstanding SAS Data Step Processing
Understanding SAS Data Step Processingguest2160992
 
AlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfAlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfSusieMaestre1
 
Introduction to sas
Introduction to sasIntroduction to sas
Introduction to sasAjay Ohri
 

Similar to Hechsp 001 Chapter 2 (20)

BAS 150 Lesson 3 Lecture
BAS 150 Lesson 3 LectureBAS 150 Lesson 3 Lecture
BAS 150 Lesson 3 Lecture
 
Introduction To Sas
Introduction To SasIntroduction To Sas
Introduction To Sas
 
Introduction to sas.pptx
Introduction to sas.pptxIntroduction to sas.pptx
Introduction to sas.pptx
 
Sap basis administration handbook
Sap basis administration handbookSap basis administration handbook
Sap basis administration handbook
 
Basics Of SAS Programming Language
Basics Of SAS Programming LanguageBasics Of SAS Programming Language
Basics Of SAS Programming Language
 
SAS Mainframe -Program-Tips
SAS Mainframe -Program-TipsSAS Mainframe -Program-Tips
SAS Mainframe -Program-Tips
 
Creating Reports in SAS Final
Creating Reports in SAS FinalCreating Reports in SAS Final
Creating Reports in SAS Final
 
Sas
SasSas
Sas
 
InduSoft Web Studio Driver Overview – SITIA and ABCIP
InduSoft Web Studio Driver Overview – SITIA and ABCIPInduSoft Web Studio Driver Overview – SITIA and ABCIP
InduSoft Web Studio Driver Overview – SITIA and ABCIP
 
SQL Performance Tuning and New Features in Oracle 19c
SQL Performance Tuning and New Features in Oracle 19cSQL Performance Tuning and New Features in Oracle 19c
SQL Performance Tuning and New Features in Oracle 19c
 
Call Execute For Everyone
Call Execute For EveryoneCall Execute For Everyone
Call Execute For Everyone
 
Basic programming
Basic programmingBasic programming
Basic programming
 
SAS - overview of SAS
SAS - overview of SASSAS - overview of SAS
SAS - overview of SAS
 
R12 d49656 gc10-apps dba 22
R12 d49656 gc10-apps dba 22R12 d49656 gc10-apps dba 22
R12 d49656 gc10-apps dba 22
 
Understanding SAS Data Step Processing
Understanding SAS Data Step ProcessingUnderstanding SAS Data Step Processing
Understanding SAS Data Step Processing
 
Sas base programmer
Sas base programmerSas base programmer
Sas base programmer
 
AlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfAlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdf
 
SAS Programming Notes
SAS Programming NotesSAS Programming Notes
SAS Programming Notes
 
Introduction to sas
Introduction to sasIntroduction to sas
Introduction to sas
 
INTRODUCTION TO SAS
INTRODUCTION TO SASINTRODUCTION TO SAS
INTRODUCTION TO SAS
 

Recently uploaded

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 

Recently uploaded (20)

YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 

Hechsp 001 Chapter 2

  • 1. Chapter 2 Getting Started with the SAS ® System
  • 2. Section 2.1 Introduction to SAS Programs
  • 3.
  • 4.
  • 5. Turning Data into information DATA Step Data Output SAS Data Set PROC Step LastName FirstName Age TORRES JAN 23 LANGKAMM SARAH 46 SMITH MICHAEL 71 WAGSCHAL NADJA 37 TOERMOEN JOCHEN 16
  • 6.
  • 7. data work.staff; infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff; run; proc means data=work.staff; class JobTitle; var Salary; run; DATA Step PROC Steps SAS Programs
  • 8.
  • 9.
  • 10. data work.staff; infile ' raw-data-file '; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff; proc means data=work.staff; class JobTitle; var Salary; run; Step Boundaries
  • 11.
  • 12.
  • 13. Section 2.2 Running SAS Programs
  • 14.
  • 15. SAS Vocabulary KEYS LOG Program Editor SAS log Enhanced Editor SUBMIT WED Editor window OUTPUT INCLUDE CLEAR LOG SAS Output
  • 16. Submitting a SAS Program When you execute a SAS program, the output generated by SAS is divided into two major parts: contains reports generated by SAS procedures and DATA steps. SAS output contains information about the processing of the SAS program, including any warning and error messages. SAS log
  • 17. SAS Log 1 data work.staff; 2 infile 'raw-data-file'; 3 input LastName $ 1-20 FirstName $ 21-30 4 JobTitle $ 36-43 Salary 54-59; 5 run; NOTE: The infile 'raw-data-file' is: File Name= 'raw-data-file', RECFM=V,LRECL=256 NOTE: 18 records were read from the infile 'raw-data-file'. The minimum record length was 59. The maximum record length was 59. NOTE: The data set WORK.STAFF has 18 observations and 4 variables. 6 proc print data=work.staff; 7 run; NOTE: There were 18 observations read from the dataset WORK.STAFF. 8 proc means data=work.staff; 9 class JobTitle; 10 var Salary; 11 run; NOTE: There were 18 observations read from the dataset WORK.STAFF.
  • 18. PRINT Procedure Output The SAS System First Obs LastName Name JobTitle Salary 1 TORRES JAN Pilot 50000 2 LANGKAMM SARAH Mechanic 80000 3 SMITH MICHAEL Mechanic 40000 4 LEISTNER COLIN Mechanic 36000 5 WADE KIRSTEN Pilot 85000 6 TOMAS HARALD Pilot 105000 7 WAUGH TIM Pilot 70000 8 LEHMANN DAGMAR Mechanic 64000 9 TRETTHAHN MICHAEL Pilot 100000 10 TIETZ OTTO Pilot 45000 11 O'DONOGHUE ART Mechanic 52000 12 WALKER THOMAS Pilot 95000 13 NOROVIITA JOACHIM Mechanic 78000 14 OESTERBERG ANJA Mechanic 80000 15 LAUFFER CRAIG Mechanic 40000 16 TORR JUGDISH Pilot 45000 17 WAGSCHAL NADJA Pilot 77500 18 TOERMOEN JOCHEN Pilot 65000
  • 19. MEANS Procedure Output The SAS System The MEANS Procedure Analysis Variable : Salary N JobTitle Obs N Mean Std Dev Minimum ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Mechanic 8 8 58750.00 19151.65 36000.00 Pilot 10 10 73750.00 22523.14 45000.00 ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Analysis Variable : Salary N JobTitle Obs Maximum ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Mechanic 8 80000.00 Pilot 10 105000.00 ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
  • 20.
  • 21.
  • 22. Command Box Output Window (behind) Current Working Directory Menus Toolbar Explorer Log Window Enhanced Editor
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43. Program Editor versus Enhanced Editor Keeps code after a submit Code not kept after a submit Can have many windows open Can only have one window open Has a blue + added to the icons Title bar: Editor Title bar: Program Editor Coloring is different. Coloring is different. Enhanced Editor Program Editor
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52. Section 2.3 Mastering Fundamental Concepts
  • 53.
  • 54.
  • 55.
  • 56. SAS Data Set Terminology SAS documentation and text in the SAS windowing environment use the following terms interchangeably: SAS Data Set Table Variable Column Observation Row
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62. Partial PROC CONTENTS Output The SAS System The CONTENTS Procedure Data Set Name SASHELP.CLASS Observations 19 Member Type DATA Variables 5 Engine V9 Indexes 0 Created Wednesday, May 12, 2004 Observation Length 40 10:53:55 PM Last Modified Wednesday, May 12, 2004 Deleted Observations 0 10:53:55 PM Protection Compressed NO Data Set Type Sorted NO Alphabetic List of Variables and Attributes # Variable Type Len 3 Age Num 8 4 Height Num 8 1 Name Char 8 2 Sex Char 1 5 Weight Num 8
  • 63. SAS Data Sets: Data Portion Numeric values Variable names Variable values LastName FirstName JobTitle Salary TORRES JAN Pilot 50000 LANGKAMM SARAH Mechanic 80000 SMITH MICHAEL Mechanic 40000 WAGSCHAL NADJA Pilot 77500 TOERMOEN JOCHEN Pilot 65000 The data portion of a SAS data set is a rectangular table of character and/or numeric data values. Variable names are part of the descriptor portion, not the data portion. Character values
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85. Missing Data Values LastName FirstName JobTitle Salary TORRES JAN Pilot 50000 LANGKAMM SARAH Mechanic 80000 SMITH MICHAEL Mechanic . WAGSCHAL NADJA Pilot 77500 TOERMOEN JOCHEN 65000 A value must exist for every variable for each observation. Missing values are valid values. A numeric missing value is displayed as a period . A character missing value is displayed as a blank .
  • 86.
  • 87.
  • 88. PROC PRINT Output The SAS System First Obs LastName Name JobTitle Salary 1 TORRES JAN Pilot 50000 2 LANGKAMM SARAH Mechanic 80000 3 SMITH MICHAEL Mechanic 40000 4 LEISTNER COLIN Mechanic 36000 5 WADE KIRSTEN Pilot 85000 6 TOMAS HARALD Pilot 105000 7 WAUGH TIM Pilot 70000 8 LEHMANN DAGMAR Mechanic 64000 9 TRETTHAHN MICHAEL Pilot 100000 10 TIETZ OTTO Pilot 45000 11 O'DONOGHUE ART Mechanic 52000 12 WALKER THOMAS Pilot 95000 13 NOROVIITA JOACHIM Mechanic 78000 14 OESTERBERG ANJA Mechanic 80000 15 LAUFFER CRAIG Mechanic 40000 16 TORR JUGDISH Pilot 45000 17 WAGSCHAL NADJA Pilot 77500 18 TOERMOEN JOCHEN Pilot 65000
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100. Section 2.4 Diagnosing and Correcting Syntax Errors
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107. In this demonstration, you open a program that has errors and submit it. Find the errors and correct them. Programs to open: c02s4d1.sas c02s4d2.sas Demonstration – Debugging a SAS Program
  • 108.
  • 109. Submit a SAS Program with Errors daat work.staff; infile 'emplist.dat' ; input LastName $ 1 - 20 FirstName $ 21 - 30 JobTitle $ 36 - 43 Salary 54 - 59 ; run ; proc print data =work.staff run; proc means data =work.staff average max ; class JobTitle; var Salary; run ; Demonstration – Debugging a SAS Program
  • 110. The SAS log contains error messages and warnings. 1 daat work.staff; ---- 14 WARNING 14-169: Assuming the symbol DATA was misspelled as daat.   2 infile ‘… emplist.dat '; 3 input LastName $ 1-20 FirstName $ 21-30 4 JobTitle $ 36-43 Salary 54-59; 5 run;   NOTE: The infile ‘… emplist.dat ' is: File Name=‘… emplist.dat ', RECFM=V,LRECL=256   NOTE: 18 records were read from the infile ‘… emplist.dat '. The minimum record length was 59. The maximum record length was 59. NOTE: The data set WORK.STAFF has 18 observations and 4 variables. Part 1 of 4 Demonstration – Debugging a SAS Program
  • 111. The SAS log contains error messages and warnings. 6 7 proc print data=work.staff 8 run; --- 22 - 200 ERROR 22-322: Syntax error, expecting one of the following: ;, (, DATA, DOUBLE, HEADING, LABEL, N, NOOBS, OBS, ROUND, ROWS, SPLIT, STYLE, UNIFORM, WIDTH. ERROR 200-322: The symbol is not recognized and will be ignored. 9   NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE PRINT used (Total process time): real time 0.06 seconds cpu time 0.06 seconds Part 2 of 4 Demonstration – Debugging a SAS Program
  • 112. The SAS log contains error messages and warnings. 10 proc means data=work.staff average max; ------- --- 22 202 ERROR 22-322: Syntax error , expecting one of the following: ;, (, ALPHA, CHARTYPE, CLASSDATA, CLM, COMPLETETYPES, CSS, CV, DATA, DESCEND, DESCENDING, DESCENDTYPES, EXCLNPWGT, EXCLNPWGTS, EXCLUSIVE, FW, IDMIN, KURTOSIS, LCLM, MAX, MAXDEC, MEAN , MEDIAN, MIN, MISSING, N, NDEC, NMISS, NONOBS, NOPRINT, NOTHREADS, NOTRAP, NWAY, ORDER, P1, P10, P25, P5, P50, P75, P90, P95, P99, PCTLDEF, PRINT, PRINTALL, PRINTALLTYPES, PRINTIDS, PRINTIDVARS, PROBT, Q1, Q3, QMARKERS, QMETHOD, QNTLDEF, QRANGE, RANGE, SKEWNESS, STDDEV, STDERR, SUM, SUMSIZE, SUMWGT, T, THREADS, UCLM, USS, VAR, VARDEF. ERROR 202-322: The option or parameter is not recognized and will be ignored. 11 class JobTitle; 12 var Salary; 13 run; Part 3 of 4 Demonstration – Debugging a SAS Program
  • 113. The SAS log contains error messages and warnings.   NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE MEANS used (Total process time): real time 0.05 seconds cpu time 0.05 seconds Part 4 of 4 Demonstration – Debugging a SAS Program
  • 114.
  • 115.
  • 116.
  • 117. data work.staff; infile 'emplist.dat' ; input LastName $ 1 - 20 FirstName $ 21 - 30 JobTitle $ 36 - 43 Salary 54 - 59 ; run ; proc print data =work.staff; run ; proc means data =work.staff mean max ; class JobTitle; var Salary; run ; Demonstration – Debugging a SAS Program
  • 118.
  • 119.
  • 120.
  • 121.
  • 122.
  • 123.
  • 124.
  • 125.
  • 126.
  • 127.
  • 128.
  • 129.
  • 130.
  • 131.
  • 132.
  • 133.
  • 134.
  • 135.
  • 136.
  • 137.
  • 138.
  • 139. Resubmitting the Program 27 data work.staff; 28 infile 'raw-data-file' ; 29 input LastName $ 1-20 FirstName $ 21-30 30 JobTitle $ 36-43 Salary 54-59; 31 run;   NOTE: 18 records were read from the infile 'raw-data-file'. The minimum record length was 59. The maximum record length was 59. NOTE: The data set WORK.STAFF has 18 observations and 4 variables. 32 33 proc print data=work.staff; 34 run;   NOTE: There were 18 observations read from the dataset WORK.STAFF. 35 36 proc means data=work.staff mean max; 37 class JobTitle; 38 var Salary; 39 run; NOTE: There were 18 observations read from the dataset WORK.STAFF.
  • 140.
  • 141.
  • 142.
  • 143.
  • 144.
  • 145.
  • 146.
  • 147.