Beruflich Dokumente
Kultur Dokumente
What is SAS..!
A Complete programming language with report formatting with statistical and mathematical capabilities.
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
INFILE Statement :
INFILE (ddname) ---for Sequential INFILE (ddname of PDS) (member name) ---for PDS INFILE (ddname) VSAM ---for VSAM
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
INPUT @position Variable [$] Informat name w.[d] DATA Empfile; INPUT @ Empcode 3. @Name $15. : RUN;
Informats type.
w. ---Standard numaric. w.d ---Standard numeric with decimal PDw.d ---Packed decimal. COMMAw.d ---commas in numbers
PROC Statement
The PROC statement is used to invoke a SAS procedure Procedure can Read SAS dataset Compute statistics Print report Sequence SAS datasets.
Outputting Reports
PROC PRINT
Automatically formats a report from the current SAS dataset.
Prints each detail record.
REPORT
EDS Employs List OBS EmpNo Name Account 1 100 AAAA XEROX 2 101 BBBB GM 3 102 CCCC XEROX
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;
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;
Report
EDS Employs List EmpNo Name Account 100 XXXX AAAA 101 YYYY BBBB
SUM Statement
The SUM Statement specifies which numeric variables will totaled.
PROC PRINT DATA=EMPFILE; SUM SALARY; TITLE EDS Employs List; RUN;
Report
EDS Employs List EmpNo Name Account Salary 101 AAAA XXXX 10000 102 BBBB YYYY 15000 ====== 250000 ======
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;
200 201
EDS Employs List Name Account Salary AAAA XXXX 10000 BBBB XXXX 10000 ====== 20000 ====== CCCC YYYY 15000 DDDD YYYY 12000 ====== 27000
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;
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;
DATA Manipulations
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;
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 ;
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);
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;
DELETE Statement
This statement to tell SAS to stop processing the current observation. DATA Empfile1; SET Personal; IF ACCOUNT = XEROX THEN DELETE; : RUN;
Thanks!