1 / 9

SAS Interactive Matrix Language Computing for Research I Spring 2012 Ramesh

SAS Interactive Matrix Language Computing for Research I Spring 2012 Ramesh. Solve this system of linear equations: 3 x + 2 y − 4z = 11 5 x − 4 y = 9 3 y + 10 z = 42 In matrix form. =. =. Reading in Data. proc iml ; n = 3 ; *scalar; b = { 11 9 42 }; *1 x 3 row vector;

walt
Download Presentation

SAS Interactive Matrix Language Computing for Research I Spring 2012 Ramesh

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. SAS Interactive Matrix Language Computing for Research I Spring 2012 Ramesh

  2. Solve this system of linear equations: • 3x + 2y − 4z = 11 • 5x − 4y = 9 • 3y + 10z = 42 • In matrix form = =

  3. Reading in Data prociml; n = 3; *scalar; b = {11942}; *1 x 3 row vector; A = {32 -4, 5 -40, 0310}; *3 x 3 matrix; print n b a; quit;

  4. Matrix Operators: Arithmetic Addition: + Subtraction: - Division, Elementwise: / Multiplication, Elementwise: # Multiplication, Matrix: * Power, Elementwise: ## Power, Matrix: ** Concatenation, Horizontal: || Concatenation, Vertical: // Number of rows: nrow() Number of columns: ncol()

  5. Subscript Operations [ ] • Addition + • Multiplication # • Mean : • Sum of squares ## • Maximum <> • Minimum >< • Index of maximum <:> • Index of minimum >:< • Transpose: ` (Near number 1 on keyboard) • Determinant: det(matrix) • Inverse: inv(matrix) • Trace: tr(matrix) • Select a single element: i,j • Select a row: i, • Select a column: ,j

  6. Creating special Matrices: • Identity matrix with dimension = size:I(size) • Matrix having # rows = nrow # cols = ncol with all elements = x :j(nrow,ncol,x) • Diagonal matrix: diag(vector) (diag(matrix)) • Block diagonal matrix: block (M1, M2, ...)

  7. Calling SAS PROC’s into IML prociml; callrandseed(9087235); y = j(400,1); callrandgen(y,normal'); z = j(100,1); callrandgen(z,'normal', 2, 2.5); x = y // z; create a var{"x"}; append; close a; submit; procunivariatedata=a; var x; histogram /kernel; run; endsubmit;

  8. Using DO loops prociml; doi=1to3; callrandseed(9087235); mean=i*2; var=0.5*i; y = j(400,1); callrandgen(y, 'normal'); z = j(100,1); callrandgen(z, 'normal',mean, var); x = y // z; createa var {"x"}; append; close a; submit; procunivariatedata=a noprint; varx; histogram/ kernel; run; endsubmit; end;

  9. datamult; • input v1 v2 v3; • datalines; • 0.801 121.41 70.42 • 0.824 127.70 72.47 • 0.841 129.20 78.20 • 0.816 131.80 74.89 • 0.840 135.10 71.21 • 0.842 131.50 78.39 • 0.820 126.70 69.02 • 0.802 115.10 73.10 • 0.828 130.80 79.28 • 0.819 124.60 76.48 • 0.826 118.31 70.25 • 0.802 114.20 72.88 • 0.810 120.30 68.23 • 0.802 115.70 68.12 • ; • prociml; • usemult; • read all into v; • X=v`*v; • print v; • run;

More Related