Blog Archives

Discover information about SAS formats… programmatically

March 20, 2017
By
Discover information about SAS formats… programmatically

SAS formats are very useful and can be used in a myriad of creative ways. For example, you can use formats to display decimal values as a fraction. However, SAS supports so many formats that it is difficult to remember details about the format syntax, such as the default field [...] The post Discover information about SAS formats... programmatically appeared first on The DO Loop.

Read more »

LEAVE and CONTINUE: Two ways to control the flow in a SAS DO loop

March 15, 2017
By
LEAVE and CONTINUE: Two ways to control the flow in a SAS DO loop

SAS programmers who have experience with other programming languages sometimes wonder whether the SAS language supports statements that are equivalent to the "break" and "continue" statements in other languages. The answer is yes. The LEAVE statement in the SAS DATA step is equivalent to the "break" statement. It provides a [...] The post LEAVE and CONTINUE: Two ways to control the flow in a SAS DO loop appeared first on…

Read more »

Find your birthday in the digits of pi

March 13, 2017
By
Find your birthday in the digits of pi

It is time for Pi Day, 2017! Every year on March 14th (written 3/14 in the US), geeky mathematicians and their friends celebrate "all things pi-related" because 3.14 is the three-decimal approximation to pi. This year I use SAS software to show an amazing fact: you can find your birthday [...] The post Find your birthday in the digits of pi appeared first on The DO Loop.

Read more »

Find a pattern in a sequence of digits

March 10, 2017
By
Find a pattern in a sequence of digits

I recently needed to solve a fun programming problem. I challenge other SAS programmers to solve it, too! The problem is easy to state: Given a long sequence of digits, can you write a program to count how many times a particular subsequence occurs? For example, if I give you [...] The post Find a pattern in a sequence of digits appeared first on The DO Loop.

Read more »

Display output conditionally with PROC DOCUMENT

March 8, 2017
By
Display output conditionally with PROC DOCUMENT

Suppose you have several discrete variables. You want to conduct a frequency analysis of these variables and print the results, but ONLY for variables that have three or more levels. In other words, you want to conditionally display some results, but you don't know which variables satisfy the condition until [...] The post Display output conditionally with PROC DOCUMENT appeared first on The DO Loop.

Read more »

Reorder the output from a BY-group analysis in SAS

March 6, 2017
By
Reorder the output from a  BY-group analysis in SAS

After reading my article about how to use BY-group processing to run 1000 regression models, a SAS programmer asked whether it is possible to reorder the output of a BY-group analysis. The answer is yes: you can use the DOCUMENT procedure to replay a portion of your output in any [...] The post Reorder the output from a BY-group analysis in SAS appeared first on The DO Loop.

Read more »

Monte Carlo estimates of joint probabilities

March 1, 2017
By
Monte Carlo estimates of joint probabilities

Monte Carlo techniques have many applications, but a primary application is to approximate the probability that some event occurs. The idea is to simulate data from the population and count the proportion of times that the event occurs in the simulated data. For continuous univariate distributions, the probability of an [...] The post Monte Carlo estimates of joint probabilities appeared first on The DO Loop.

Read more »

Point/Counterpoint: Should a programming language accept misspelled keywords?

February 27, 2017
By
Point/Counterpoint: Should a programming language accept misspelled keywords?

Longtime SAS programmers know that the SAS DATA step and SAS procedures are very tolerant of typographical errors. You can misspell most keywords and SAS will "guess" what you mean. For example, if you mistype "PROC" as "PRC," SAS will run the program but write a warning to the log: [...] The post Point/Counterpoint: Should a programming language accept misspelled keywords? appeared first on The DO Loop.

Read more »

Quantile estimates and the difference of medians in SAS

February 22, 2017
By
Quantile estimates and the difference of medians in SAS

Sometimes SAS programmers ask about how to analyze quantiles with SAS. Common questions include: How can I compute 95% confidence intervals for a median in SAS? How can I test whether the medians of two independent samples are significantly different? How can I repeat the previous analyses with other percentiles, [...] The post Quantile estimates and the difference of medians in SAS appeared first on The DO Loop.

Read more »

The distribution of colors for plain M&M candies

February 20, 2017
By
The distribution of colors for plain M&M candies

Many introductory courses in probability and statistics encourage students to collect and analyze real data. A popular experiment in categorical data analysis is to give students a bag of M&M® candies and ask them to estimate the proportion of colors in the population from the sample data. In some classes, [...] The post The distribution of colors for plain M&M candies appeared first on The DO Loop.

Read more »


Subscribe

Email:

  Subscribe