Tag Archives: howto

Data about each month (SAS)

A SAS code to generate information about each month such as the number of days in the month, week days, hours, work hours, etc. using intck and intnx function. It’s also a good example of using a DATA step to generate a data set without an input data set (i.e., no SET or MERGE statements). Continue reading

Posted in Data set, SAS | Tagged , , | Leave a comment

Dummy coding in SAS

Here is a macro to generate binary features (also called dummy coding) from a nominal variable (also called a categorical variable, such as eye color). The automation saves time and avoids mistakes when there are many possible values to a category or the values can change. Continue reading

Posted in SAS | Tagged , , , | Leave a comment

Using SQLObject with Microsoft SQL Server and Windows Authentication

Here is how to use Windows Authentication to connect to Microsoft SQL Server with SQLObject. Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

Easy sortable HTML tables in SAS ODS

Today Charlie Huang posted a SAS HTML table sorting demo, but without automation. Here is a fully automated implementation in SAS. The developer does not need to manually edit the HTML, and the user simply clicks any column and it sorts instantly client-side in the web browser. The feature is automatically applied to all SAS tables in the ODS HTML output. Continue reading

Posted in SAS | Tagged , , | Leave a comment

Calculate Net Promoter Score in PROC TABULATE or SQL

This demonstrates an easy way to calculate the Net Promoter Score, a measure of customer loyalty, in SAS’s PROC TABULATE or PROC SQL. I prefer to use PROC TABULATE because of its power for various summaries. In the example we … Continue reading

Posted in SAS | Tagged , , | Leave a comment

100% stacked bar chart in SAS’s SGPLOT

A 100% stacked bar chart is useful for comparing the relative frequencies of an m x n table where frequencies in m are very different. While this is easy to do in Excel, SAS requires an extra step, which you … Continue reading

Posted in Uncategorized | Tagged , , , , | 1 Comment

Comparing continuous distributions with R

In R we’ll generate similar continuous distributions for two groups and give a brief overview of statistical tests and visualizations to compare the groups. Though the fake data are normally distributed, we use methods for various kinds of continuous distributions. … Continue reading

Posted in Uncategorized | Tagged , , , , , | Leave a comment

Convert written numbers to Arabic numerals

In Natural Language Processing it can be helpful within a larger body of text to standardize written numbers to Arabic numerals. For example, we will change “I am forty-six years old” to “I am 46 years old,” so the age … Continue reading

Posted in SAS | Tagged , , , | Leave a comment

Scales and transformations in ggplot2 0.9.0

Some R code designed for ggplot2 0.8.9 is not compatible with ggplot2 0.9.0, and today the ggplot2 web site has outdated documentation which gives this broken example: Dennis Murphy points to the ggplot2 0.9.0 transition guide from where I derived … Continue reading

Posted in Bugs | Tagged , , , , | Leave a comment

Checking return codes for errors in SAS

You should check for error return codes in any SAS programs that run unattended in batch jobs, so you can handle the exception properly. For example, if the data are invalid, you don’t want to generate reports or insert bad … Continue reading

Posted in Data stewardship, SAS | Tagged , , , | 4 Comments