In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how the basic functions of IML programming are, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
SAS/IML is a module using matrix language, matrix is very convenient for statistical calculation, and the typical representative is the solution of multivariate linear model. The rows in the matrix represent observations, and the columns can represent variables. Character variables and numeric variables take all. Here are the basic functions of IML, which are only a small part of it.
Matrix operation function
Proc iml; / * declares iml module * / xroom1; y = {1 23}; z = {1 23, 3 56}; o = {'abc'' opq', 'lmn'' rst'}; n_z=nrow (z); / * Matrix dimension, column dimension nrow (), ncol () * / p_o=ncol (o); type_o=type (o) / * type () matrix type, character type C or numeric type N or both include * / nlen=nleng (o); / * nleng matrix length, several strings * / len=length (o); / * length () the character of each string in the matrix, of course, the string length can be changed * / print xjinyjue zjinzo naughz; / * display matrix value * / quit
Using function to create Matrix
Proc iml; Clearj (10recollection 3.14); / * J () function produces a constant matrix with 10 rows and one column 3.14cm / rsquj (1pr 5); / * a row and five columns matrix with the default value of 1cm / mquoj (10L5); / * 10 rows and 5 columns of 0 matrix * / miss=j (3L2); / * 3 rows and 2 columns missing value matrix * / g=repeat ({0 1}, 3J2) / * the REPEAT () function can produce a more general matrix * / seed=j (10); need=uniform (seed) can perform arithmetic calculations and produce a matrix with fixed spacing * / seed=j (10). / * generate pseudorandom matrix, seed is 1 random / / * if you need to generate a large number of pseudorandom numbers, consider RANDGEN program * / call randseed (123); / * seed * / xonomj (10L1); / * x is a column vector * / eQuexx; / * x assign a value to eBay / call randgen (x, "Uniform"); / * generate random vector * / call randgen (e, "Normal"); y=3*x+2+e / * regression model * / print cdepartment r department m department misc iml; iml; s = {12 3, 4 56, 7 8 9, 10 11 12}; transpose=t (s); / * matrix transpose, T () function completes * / s2=shape (sforce 6); / * SHAPE () function is used for matrix reorganization, S2 is a 6-row matrix * / s 3 entries [3L2] / * extract a certain value from the matrix and find the number of rows and rows to complete * / s 4 / s [1 print transpose,s2,s3,s4,s5,s6 2]; s 5 / s [s 4]; / * you can reconstruct the matrix * / s6=vecdiag (s) based on the extraction number; / * vecdiag, you can find the diagonal matrix of the matrix * / print transpose,s2,s3,s4,s5,s6; quit
The function of iml for data management
APPEND adds observations to the end of a SAS data set
CLOSE closes a SAS data set
CREATE creates and opens a new SAS data set for input and output
DELETE marks observations for deletion in a SAS data set
EDIT opens an existing SAS data set for input and output
FIND finds observations
INDEX indexes variables in a SAS data set
LIST lists observations
PURGE purges all deleted observations from a SAS data set
READ reads observations into IML variables
REPLACE writes observations back into a SAS data set
RESET DEFLIB names default libname
SAVE saves changes and reopens a SAS data set
SETIN selects an open SAS data set for input
SETOUT selects an open SAS data set for output
SHOW CONTENTS shows contents of the current input SAS data set
SHOW DATASETS shows SAS data sets currently open
SORT sorts a SAS data set
SUMMARY produces summary statistics for numeric variables
USE opens an existing SAS data set for input
Simple example:
The following is the simple use of the function * / use class; show datasets contents; reset deflib=work; m = {3 69 13}; n = {name sex age weight}; list all point m var n where (sex='F'); use class; read all var {name height}; read all var _ num_ into x; read all var _ num_ into femal where (sex= "F"); print xQuery Edit class; find all where (name= {'HENRY'}) into d; delete point=d; delete all where (age > 12); create class2 from class; setin class2 point 0; sum=0; do data; read next var (weight); sum=sum+weight; end; print sum; create ratio2 var (name htwt); append; show contents; close ratio2; summary var {' height' 'weight'} class {sex} stat {mean std} opt {save}; sort class out=sorted by name Index sex; purge
Simple logic programming
Proc iml; a = {17 22 13 10}; if max (a)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.