The Do Loop

The jackknife method to estimate standard errors in SAS

One way to assess the precision of a statistic (a point estimate) is to compute the standard error, which is the standard deviation of the statistic’s sampling distribution. A relatively large standard error indicates that the point estimate should be viewed with skepticism, either because the sample size is small or because the data themselves… Continue reading The jackknife method to estimate standard errors in SAS

The Do Loop

Two simple ways to construct a log-likelihood function in SAS

Maximum likelihood estimation (MLE) is a powerful statistical technique that uses optimization techniques to fit parametric models. The technique finds the parameters that are “most likely” to have produced the observed data. SAS provides many tools for nonlinear optimization, so often the hardest part of maximum likelihood is writing down the log-likelihood function. This article… Continue reading Two simple ways to construct a log-likelihood function in SAS

The Do Loop

The IFN function versus the IF-THEN/ELSE statement in SAS

The canonical example is the LOG function, which is defined only for positive arguments. For example, to evaluate the LOG function on a sequence of (possibly non-positive) values, you can use the following IF-THEN/ELSE logic: data Log; input x @@; if x > 0 then logX = log(x); else logX = .; datalines; -1 1… Continue reading The IFN function versus the IF-THEN/ELSE statement in SAS

The Do Loop

On the SMOOTHCONNECT option in the SERIES statement

By default, when you use the SERIES statement in PROC SGPLOT to create a line plot, the observations are connected (in order) by straight line segments. However, SAS 9.4m1 introduced the SMOOTHCONNECT option which, as the name implies, uses a smooth curve to connect the observations. In Sanjay Matange’s blog, he shows an example where… Continue reading On the SMOOTHCONNECT option in the SERIES statement

The Do Loop

INTCK and INTNX: Two essential functions for computing intervals between dates in SAS

The number of living presidents is constant during the time interval between inaugurations and deaths of presidents. The data was taken from a Wikipedia table (shown below) that shows the number of years and days between events. This article shows how you can use the INTCK and INTNX functions in SAS to compute the time… Continue reading INTCK and INTNX: Two essential functions for computing intervals between dates in SAS

The Do Loop

Simulate lognormal data in SAS

A SAS customer asked how to simulate data from a three-parameter lognormal distribution as specified in the PROC UNIVARIATE documentation. In particular, he wanted to incorporate a threshold parameter into the simulation. Simulating lognormal data is easy if you remember an important fact: if X is lognormally distributed, then Y=log(X) is normally distributed. The converse… Continue reading Simulate lognormal data in SAS

The Do Loop

Visualize an ANOVA with two-way interactions

There are several ways to visualize data in a two-way ANOVA model. Most visualizations show a statistical summary of the response variable for each category. However, for small data sets, it can be useful to overlay the raw data. This article shows a simple trick that you can use to combine two categorical variables and… Continue reading Visualize an ANOVA with two-way interactions