Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
4.3. Transferring Data between Matrices and Procedures 91 In the program, the matrix x is defined prior to calling the UNIVARIATE procedure. After the UNIVARIATE procedure exits, the matrix is still available for further computations. This behav- ior is in contrast to the standard behavior in SAS programs where calling a new procedure (here, UNIVARIATE) causes the previous procedure (here, IML) to exit. The SUBMIT block enables you to call any SAS procedure, DATA step, or macro as if it were a built-in SAS/IML subroutine. Any variables in your IMLPlus program that were in scope prior to calling the SUBMIT block are still in scope after calling the SUBMIT block. Programming Tip: Use the SUBMIT and ENDSUBMIT statements to call a SAS procedure or DATA step from an IMLPlus program. The simple example in this section merely prints some statistics about the Budget variable; there is no interaction between the IMLPlus portion of the program and the call to the UNIVARIATE proce- dure. The next sections show how to transfer data between SAS/IML matrices and SAS procedures, and how to pass parameters from SAS/IML software into SAS procedures. 4.3 Transferring Data between Matrices and Procedures The technique that is described in the previous section becomes more powerful when the SAS/IML statements in your IMLPlus program interact with the procedure call. The following example mod- ifies a program discussed on page 58. /* write data to SAS procedure; /* generate bivariate sample */ call randseed(12345); x = j(100, 1); e = j(100, 1); call randgen(x, "Uniform"); call randgen(e, "Normal"); beta = {2, 3}; d = j(100, 1, 1) || x; y = d*beta + e; create MyData var {"x" "y"}; append; close MyData; read results into matrix */ /* /* /* /* /* set seed for RANDGEN allocate 100 x 1 vector allocate 100 x 1 vector fill x; values from uniform dist fill e; values from normal dist */ */ */ */ */ */ */ */ */ /* coefficients for model /* append intercept column to data /* response plus normal error term /* write sample to MyData data set /* use GLM procedure to estimate parameters for regression model submit; /* IMLPlus statement proc glm data=MyData; model y = x; ods output ParameterEstimates=PE; /* write table to data set run; endsubmit; /* IMLPlus statement */ */ */ */ Wicklin, Rick. Statistical Programming with SAS/IML® Software. Copyright © 2010, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED. For additional SAS resources, visit support.sas.com/publishing.