Posts Tagged ‘ Tips and Techniques ’

Access rows or columns of a matrix by names

October 1, 2012
By
Access rows or columns of a matrix by names

Did you know that you can index into SAS/IML matrices by using unique strings that you assign via the MATTRIB statement? The MATTRIB statement associates various attributes to a matrix. Usually, these attributes are only used for printing, but you can also use the ROWNAME= and COLNAME= attributes to subset
Read more »

Tags: , ,
Posted in SAS | Comments Off

Extract the lower triangular elements of a matrix

August 16, 2012
By
Extract the lower triangular elements of a matrix

It is common to want to extract the lower or upper triangular elements of a matrix. For example, if you have a correlation matrix, the lower triangular elements are the nontrivial correlations between variables in your data. As I've written before, you can use the VECH function to extract the
Read more »

Tags: , , ,
Posted in SAS | Comments Off

How to get data values out of ODS graphics

August 1, 2012
By
How to get data values out of ODS graphics

Many SAS procedures can produce ODS statistical graphics as naturally as they produce tables. Did you know that it is possible to obtain the numbers underlying an ODS statistical graph? This post shows how. Suppose that a SAS procedure creates a graph that displays a curve and that you want
Read more »

Tags: , , ,
Posted in SAS | Comments Off

Create an ID vector for repeated measurements

June 27, 2012
By
Create an ID vector for repeated measurements

I often use the SAS/IML language for simulating data with certain known properties. In fact, I'm writing a book about the Simulating Data with SAS. When I simulate repeated measurements (sometimes called replicated data), I often want to generate an ID variable that identifies which measurement is associated with which
Read more »

Tags: , ,
Posted in SAS | Comments Off

Programming tip: Avoid testing floating point values for equality

June 25, 2012
By

No matter what statistical programming language you use, be careful of testing for an exact value of a floating-point number. This is known in the world of numerical analysis as "10.0 times 0.1 is hardly ever 1.0" (Kernighan and Plauger, 1974, The Elements of Programming Style). There are many examples
Read more »

Tags: , , ,
Posted in SAS | Comments Off

Rename many variables that have numerical suffixes and a common prefix

June 4, 2012
By

I recently read a blog post in which a SAS user had to rename a bunch of variables named A1, A2,..., A10, such as are contained in the following data set: /* generate data with variables A1-A10 */ data A; array A[10] A1-A10 (1); do i = 1 to 10;
Read more »

Tags: , ,
Posted in SAS | Comments Off

An easy way to define a library of user-defined functions

May 31, 2012
By

In the SAS/IML language, a user-defined function or subroutine is called a module. Modules are used to extend the capability of the SAS/IML language. In my blog posts, I usually define a module in a PROC IML session and then immediately use it. However, sometimes it is useful to store
Read more »

Tags: , ,
Posted in SAS | Comments Off

Did you know that PROC IML automatically loads certain modules?

May 29, 2012
By

In the SAS/IML language, a user-defined function or subroutine is called a module. Modules are used to extend the capability of the SAS/IML language. Usually you need to explicitly load modules before you use them, but there are two cases where PROC IML loads a module automatically. Modules in IMLMLIB
Read more »

Tags: , , ,
Posted in SAS | Comments Off

Welcome!

SAS-X.com offers news and tutorials about the various SAS® software packages, contributed by bloggers. You are welcome to subscribe to e-mail updates, or add your SAS-blog to the site.

SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.