More on IML Statements and Functions Working with SAS Data Sets IML Modules
PROC IML #2SAS Interactive Matrix Language, An Introduction
JC Wang
wang (WMU) PROC IML #2 Lecture 25 1 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
Outline
1 More on IML Statements and FunctionsDisplaying Matrices with Row and Column HeadingsFlow Control StatementsMore Useful Functions/Call Routines
2 Working with SAS Data SetsOpening a SAS Data SetReading SAS Data SetCreating SAS Data Set
3 IML ModulesUse of IML ModulesDefining and Executing ModulesStoring and Retrieving Modules
wang (WMU) PROC IML #2 Lecture 25 2 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
Using the AUTONAME OptionCodesRESET AUTONAME;a = {126 297 156, 306 498 349,
88 61 75, 27 17 44};PRINT Using AUTONAME, a;
OutputUsing AUTONAME
ACOL1 COL2 COL3
ROW1 126 297 156ROW2 306 498 349ROW3 88 61 75ROW4 27 17 44
wang (WMU) PROC IML #2 Lecture 25 3 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
Using the AUTONAME OptionCodesRESET AUTONAME;a = {126 297 156, 306 498 349,
88 61 75, 27 17 44};PRINT Using AUTONAME, a;
OutputUsing AUTONAME
ACOL1 COL2 COL3
ROW1 126 297 156ROW2 306 498 349ROW3 88 61 75ROW4 27 17 44
wang (WMU) PROC IML #2 Lecture 25 3 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
Using the AUTONAME OptionCodesRESET AUTONAME;a = {126 297 156, 306 498 349,
88 61 75, 27 17 44};PRINT Using AUTONAME, a;
OutputUsing AUTONAME
ACOL1 COL2 COL3
ROW1 126 297 156ROW2 306 498 349ROW3 88 61 75ROW4 27 17 44
wang (WMU) PROC IML #2 Lecture 25 3 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
Using the ROWNAME= and COLNAME= OptionsCodesrn = {Underweight "Normal"
"Overweight" Obese};cn = {"Britian" "Canada" "United States"};PRINT Using ROWNAME= and COLNAME=,
a[ROWNAME=rn COLNAME=cn];
OutputUsing ROWNAME= and COLNAME=
ABritian Canada United States
Underweight 126 297 156Normal 306 498 349Overweight 88 61 75Obese 27 17 44
wang (WMU) PROC IML #2 Lecture 25 4 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
Using the ROWNAME= and COLNAME= OptionsCodesrn = {Underweight "Normal"
"Overweight" Obese};cn = {"Britian" "Canada" "United States"};PRINT Using ROWNAME= and COLNAME=,
a[ROWNAME=rn COLNAME=cn];
OutputUsing ROWNAME= and COLNAME=
ABritian Canada United States
Underweight 126 297 156Normal 306 498 349Overweight 88 61 75Obese 27 17 44
wang (WMU) PROC IML #2 Lecture 25 4 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
Using the ROWNAME= and COLNAME= OptionsCodesrn = {Underweight "Normal"
"Overweight" Obese};cn = {"Britian" "Canada" "United States"};PRINT Using ROWNAME= and COLNAME=,
a[ROWNAME=rn COLNAME=cn];
OutputUsing ROWNAME= and COLNAME=
ABritian Canada United States
Underweight 126 297 156Normal 306 498 349Overweight 88 61 75Obese 27 17 44
wang (WMU) PROC IML #2 Lecture 25 4 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
Using the MATTRIB StatementCodesMATTRIB a ROWNAME=rnCOLNAME=({"Britian" "Canada" "United States"})LABEL=Body Weight ClassificationFORMAT=3.;
PRINT Using MATTRIB Statement, a;
OutputUsing MATTRIB Statement
Body Weight ClassificationBritian Canada United States
Underweight 126 297 156Normal 306 498 349Overweight 88 61 75Obese 27 17 44
wang (WMU) PROC IML #2 Lecture 25 5 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
Using the MATTRIB StatementCodesMATTRIB a ROWNAME=rnCOLNAME=({"Britian" "Canada" "United States"})LABEL=Body Weight ClassificationFORMAT=3.;
PRINT Using MATTRIB Statement, a;
OutputUsing MATTRIB Statement
Body Weight ClassificationBritian Canada United States
Underweight 126 297 156Normal 306 498 349Overweight 88 61 75Obese 27 17 44
wang (WMU) PROC IML #2 Lecture 25 5 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
Using the MATTRIB StatementCodesMATTRIB a ROWNAME=rnCOLNAME=({"Britian" "Canada" "United States"})LABEL=Body Weight ClassificationFORMAT=3.;
PRINT Using MATTRIB Statement, a;
OutputUsing MATTRIB Statement
Body Weight ClassificationBritian Canada United States
Underweight 126 297 156Normal 306 498 349Overweight 88 61 75Obese 27 17 44
wang (WMU) PROC IML #2 Lecture 25 5 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
IF-THEN/ELSE StatementsIF expression THEN statement1;ELSE statement2;
scalar expression expected;matrix expression is true only if all elements in it are nonzeroand nonmissing; henceit is equivalent toIF ALL(expression)...;nesting is allowed, e.g.:IF expr-1 THENIF expr-2 THEN statement-1;ELSE statement-2;
ELSE statement-3
if expression is of the form ANY(matrix) then its value is falseonly if all elements are false (zero or missing)
wang (WMU) PROC IML #2 Lecture 25 6 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
IF-THEN/ELSE StatementsIF expression THEN statement1;ELSE statement2;
scalar expression expected;matrix expression is true only if all elements in it are nonzeroand nonmissing; henceit is equivalent toIF ALL(expression)...;nesting is allowed, e.g.:IF expr-1 THENIF expr-2 THEN statement-1;ELSE statement-2;
ELSE statement-3
if expression is of the form ANY(matrix) then its value is falseonly if all elements are false (zero or missing)
wang (WMU) PROC IML #2 Lecture 25 6 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
IF-THEN/ELSE StatementsIF expression THEN statement1;ELSE statement2;
scalar expression expected;matrix expression is true only if all elements in it are nonzeroand nonmissing; henceit is equivalent toIF ALL(expression)...;nesting is allowed, e.g.:IF expr-1 THENIF expr-2 THEN statement-1;ELSE statement-2;
ELSE statement-3
if expression is of the form ANY(matrix) then its value is falseonly if all elements are false (zero or missing)
wang (WMU) PROC IML #2 Lecture 25 6 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
IF-THEN/ELSE StatementsIF expression THEN statement1;ELSE statement2;
scalar expression expected;matrix expression is true only if all elements in it are nonzeroand nonmissing; henceit is equivalent toIF ALL(expression)...;nesting is allowed, e.g.:IF expr-1 THENIF expr-2 THEN statement-1;ELSE statement-2;
ELSE statement-3
if expression is of the form ANY(matrix) then its value is falseonly if all elements are false (zero or missing)
wang (WMU) PROC IML #2 Lecture 25 6 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
IF-THEN/ELSE StatementsIF expression THEN statement1;ELSE statement2;
scalar expression expected;matrix expression is true only if all elements in it are nonzeroand nonmissing; henceit is equivalent toIF ALL(expression)...;nesting is allowed, e.g.:IF expr-1 THENIF expr-2 THEN statement-1;ELSE statement-2;
ELSE statement-3
if expression is of the form ANY(matrix) then its value is falseonly if all elements are false (zero or missing)
wang (WMU) PROC IML #2 Lecture 25 6 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
IF-THEN/ELSE StatementsIF expression THEN statement1;ELSE statement2;
scalar expression expected;matrix expression is true only if all elements in it are nonzeroand nonmissing; henceit is equivalent toIF ALL(expression)...;nesting is allowed, e.g.:IF expr-1 THENIF expr-2 THEN statement-1;ELSE statement-2;
ELSE statement-3
if expression is of the form ANY(matrix) then its value is falseonly if all elements are false (zero or missing)
wang (WMU) PROC IML #2 Lecture 25 6 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
DO Groups
DO;statements
END;
nesting DO groups are allowed;use proper indentations for good programming practice.
wang (WMU) PROC IML #2 Lecture 25 7 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
DO Groups
DO;statements
END;
nesting DO groups are allowed;use proper indentations for good programming practice.
wang (WMU) PROC IML #2 Lecture 25 7 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
DO Groups
DO;statements
END;
nesting DO groups are allowed;use proper indentations for good programming practice.
wang (WMU) PROC IML #2 Lecture 25 7 / 38
More on IML Statements and Functions Working with SAS Data Sets IML Modules
Iterative ExecutionDO DATA Statement
DO DATA ;statements;
END;
variable = index variable, start = start value, stop = stopvalue;exiting loop at end-of-file or stopping value, whichever occurs first;is preceded with an INFILE statement which works similarly to theDATA steps INFILE statement with only limited optionscontains an INPUT statement within this type of iterative executionwith formatted style input recommended;other IML matrix language can go in statements.
See Example ProcIML10.sas.
wang (WMU) PROC IML #2 Lecture 25 8 / 38
Top Related