1 / 35

Welcome to SAS…Session..!

Welcome to SAS…Session..!. What is SAS..!. A Complete programming language with report formatting with statistical and mathematical capabilities. SAS Programming Structure. 1st Part.. The first part called the DATA step , This part describes your input data

brina
Télécharger la présentation

Welcome to SAS…Session..!

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Welcome toSAS…Session..!

  2. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.

  3. SAS Programming Structure 1st Part.. • The first part called the DATA step, This part describes your input data allows you to modify that data with arithmetic operations and logical decisions. The DATA Step will format your data into a special file called SASdataset.

  4. 2nd Part .. • The second part of SAS is a library of canned routines called PROCEDURES. The procedures can only use SAS datasets as input. The Data step must always have preceded the Procedure section. The procedures are executed by coding a special statement in SAS called a PROC statement

  5. Functions of DATA Step. • Reads raw data from input files. • Selects records from input files. • Writes out the SASdatasets. Statements used in the DATA Step: • DATA Statement. DATA EMPFILE --Temporary File. DATA UDEM.EMPFILE ---Permanent file

  6. INFILE Statement : INFILE (ddname) ---for Sequential INFILE (ddname of PDS) (member name) ---for PDS INFILE (ddname) VSAM ---for VSAM

  7. INPUT Statement : The INPUT statement describes the input data record from the INFILE statement. Standard record input : (fixed length) INPUT variable [$] [startcolumn-endcolumn] [.decimal] DATA Empfile; INPUT Empno 1-3 Name $ 4-19 Salary 20-26 .2

  8. Non standard record input : (like Packed dec...) INPUT @position Variable [$] Informat name w.[d] DATA Empfile; INPUT @ Empcode 3. @Name $15. : RUN;

  9. Informats type. w. ---Standard numaric. w.d ---Standard numeric with decimal PDw.d ---Packed decimal. COMMAw.d ---commas in numbers

  10. PROC Statement • The PROC statement is used to invoke a SAS procedure Procedure can- • Read SAS dataset • Compute statistics • Print report • Sequence SAS datasets.

  11. Outputting Reports

  12. PROC PRINT • Automatically formats a report from the current SAS dataset. • Prints each detail record. • Column headings default to the variable name but may be altered.

  13. Syntax for to Print the default Report DATA EMPFILE; INFILE PERSON; INPUT EmpNo $ 1-3 Name $ 4-19 DOB 20-26 Account 27-35; PROC PRINT; TITLE ‘EDS Employs List’; RUN;

  14. REPORT EDS Employs List OBS EmpNo Name Account 1 100 AAAA XEROX 2 101 BBBB GM 3 102 CCCC XEROX

  15. Using the SORT Procedure with PROC PRINT PROC SORT; BY ACCOUNT; PROC PRINT DATA = EMPFILE; TITLE ‘EDS Employs List’; RUN;

  16. VAR Statement • VAR Statement determines which variables will be printed in the report. • Order of the variables in the VAR statement is the order the variables appear in the report. PROC PRINT DATA=EMPFILE; VAR ACCOUNT EMPNO NAME; TITLE ‘EDS Employs List’; RUN;

  17. ID Statement • Suppresses printing the OBS column on the report. • More than one variable can be listed in the ID statement. PROC PRINT DATA=EMPFILE; ID EMPNO; TITLE ‘EDS Employs List’; RUN;

  18. Report EDS Employs List EmpNo Name Account 100 XXXX AAAA 101 YYYY BBBB

  19. SUM Statement • The SUM Statement specifies which numeric variables will totaled. PROC PRINT DATA=EMPFILE; SUM SALARY; TITLE ‘EDS Employs List’; RUN;

  20. Report EDS Employs List EmpNo Name Account Salary 101 AAAA XXXX 10000 102 BBBB YYYY 15000 ====== 250000 ======

  21. BY Statement • This is just like Control Break in COBOL. • If BY Statements are present with SUM Statement each BY group will also be totaled. PROC PRINT ; BY ACCOUNT; SUM SALARY; TITLE ‘EDS Employs List’; RUN;

  22. EDS Employs List EmpNo Name Account Salary 100 AAAA XXXX 10000 101 BBBB XXXX 10000 ====== 20000 ====== 200 CCCC YYYY 15000 201 DDDD YYYY 12000 ====== 27000 ======

  23. LABLE & SPLIT Statements • LABLE Statement is used to assign alternate column headers to variables. • The SPLIT option on the PROC PRINT statement allows multiple line alternate column headings for the report. • A SPLIT character is identified with the SPLIT option.When that character is used in the LABLE text causes the label to split into multiple lines at that point

  24. Cont.. • Any character may be used to split the line. • The LABLE option on the PROC PRINT statement tells SAS to use the alternative label coded in the LABEL statement. PROC PRINT LABEL/SPLIT=‘*’; : LABEL ACCOUNT=‘CLINT*NAME’;

  25. TITLE / FOOTNOTE Statements • Lines from the top correspond to the number in the TITLE. • Allows up to 10 title lines to be placed at the top of each page of the report. • IF TITLE line within a group of titles is not coded it will result in a blank line • FOOTNOTE is similar to TITLE Statement.

  26. PAGEBY Statement • The PAGEBY variable is used with the BY Statement using the same variable. The page break occurs when the specified BY variable changes value . PROC PRINT; BY ACCOUNT; PAGEBY ACCOUNT; : RUN;

  27. DATA Manipulations

  28. IF Statement • Indicates which observations are included in the output SAS data set. • When multiple logical expressions are used (with the AND and OR ) the ANDs are resolved first. • Syntax: IF var1 = var2 AND/OR var3 = var4;

  29. WHERE Statement • Used to select observations from a SAS daaset. • Operators for the WHERE statement include all operators of the IF statement • Operators exclusively for WHERE: WHERE Salary BETWEEN 15000 AND 20000 ;

  30. Cont.. WHERE Name CONTAINS ‘SRINIVAS’; ------Searches for a character string WHERE Name LIKE ‘S%’; --selects name with the first character ‘S’ WHERE Account IN (‘GM’,’XEROX’);

  31. DO and END Statement • Execution of a DO statement specifies that all statements between the DO and its matching END are to be executed. DATA Empfile; SET Personal; IF ACCOUNT = ‘XEROX’ THEN DO; NEWSAL= SALARY*1.2; ELSE DO; NEWSAL=SALARY; END;

  32. DROP Statement • The DROP is used to specify variables that are not included in the SASdatasets being created. DATA Empfile1; SET Personal; WHERE ACCOUNT = ‘XEROX’; DROP SALARY; RUN;

  33. DELETE Statement • This statement to tell SAS to stop processing the current observation. DATA Empfile1; SET Personal; IF ACCOUNT = ‘XEROX’ THEN DELETE; : RUN;

  34. SAS System options • The OPTION statement changes SAS system options. • OPTION option1 option2..; Some options: DATE, NODATE --- Puts date on title page CENTER, NOCENTER----Centers output LS ---- Linesize for output 64-225 NUMBER, NONUMBER---Page numbering

  35. Thanks…!

More Related