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

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 

Recently uploaded (20)

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 

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.