INCLUDE_DATA

Category Archives: Programming

Wicket Homepage Redirecting

With the Wicket Java Web framework where a lot of magic happens behind the scenes, and almost no XML needs to be configured. Most of it is done with Java. It has a lot of pretty cool features. I just came across this one.
In the init setup of your class that extends WebApplication, you can [...]

SQL Optimization: Union vs. Union All

Everyone should learn the difference between Union and Union All. Knowing it will make you a better programmer, and it’s fairly trivial to understand.
SELECT * FROM apples
UNION
SELECT * FROM oranges
When you know for a fact that there will never be any common rows between the apples table and the oranges table, this query will be [...]

Abusing Hash objects as a Stack in SAS Data Step

Everyone in the computer science field (should) eventually learn or realize that any recursive function can be rewritten as an iterative process with the aid of a stack. Since a SAS Data Step is iterative, it’s fairly easy to look up children of a tree node in metadata, but nearly impossible to recursively look up [...]

Looping through SAS metadata objects

The following is my attempt at SAS Golf, where in a Data Step, I try to list the associations of a metadata object to the log. This is basically just taking advantage of combining SAS for loops with SAS while loops. I thought it was cool. Usually I find myself doing this with metadata_getnasn, metadata_getnprp, [...]

Dramatically Increasing SAS DI Studio performance of SCD Type-2 Loader Transforms

In SAS DI Studio 3.4 (and I imagine in future versions), the prepackaged code for the SCD Type-2 Loader works like this: Does the dataset exist? If not, create an empty dataset with structure and indexes as defined from metadata. Then detect differences between it and the source dataset and the target dataset, expire any [...]

Easy Inserting/Appending Libraries into FMTSEARCH path lists in SAS 9.2

In SAS 9.1.3 and prior, Options list (such as FMTSEARCH for libraries with format catalogs, and SASAUTOS for paths that contain macros shared across jobs) were annoying to work with. If you have nested code that wants to add a library or a path the list, doing so like this could potentially clobber statements executed [...]

Counting distinct variables in SQL with SAS

One way to get the count of distinct variables, which works in most flavors of SQL, is to use a subquery. For instance, in Oracle this is:
SELECT count(SELECT DISTINCT foo FROM table) FROM dual
In SAS, using PROC SQL, you can do that too, but you can also simply do this:
SELECT count(distinct foo) FROM table

For loops in SAS

When coding for loops in SAS, one neat thing to remember is that all of the parts of it are optional.
start <TO stop> <BY increment> <WHILE(expression) | UNTIL(expression)>
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000201276.htm
So in another language, what might be
for(int i=0;i < max;i++) {
In SAS, you can leave out the “by 1″, since it’s the default increment. So this would be
do [...]

Removing formats from all variables in a SAS Dataset

In SAS, every field/variable in a table/dataset can be given a format. This format tells SAS how to display the data. The following datastep will create a table called “formatted” having 1 row containing 3 variables: x, y, and d.
data formatted;
x=9000;
y=42;
now=16761;
format x comma6.;
format y dollar5.;
[...]

Sending HTTP Requests without Reloading and without AJAX

Supposing I have a simple HTML form that looks like this:
<form method=”post” action=”/SomeServlet”>
<input type=”text” name=”message” value=”Hello Server” />
<input type=”submit” value=”Send” />
</form>
And supposing I have a Servlet mapped at the path /SomeServlet, consisting of the code:
public class SomeServlet extends HttpServlet {
protected void doPost(HttpServletRequest request,
[...]