philihp.com

Category: Programming

Automatic Base SAS Library Assignments

If you stick a file named autoexec.sas in the directory where SAS is installed, it will run automatically when SAS starts up. By default, this place is C:\Program Files\SASHome\SASFoundation\9.3. This has worked since at least SAS 8.2, probably before. I like to use my Windows desktop as a temporary staging area, so I have my [...]

Finding the Center of US Counties in SAS

I had a problem where I needed the center longitude and latitude of each US county. SAS comes with some datasets containing map data in the format of tables that trace a line around the borders of counties. I was interested in the MAPSGFK.US_COUNTIES dataset, which has data that looks like this: The State and [...]

Bayesian Averaging in SAS

Hypothetical situation, lets say you’ve got a list of movies that you want to rank in a website or a report or something, and you have user-submitted ratings for them, but some are more popular than others, so your data looks like this: data ratings; input name $ rating; datalines; Lincoln 9 Lincoln 8 Lincoln [...]

How To Save Struts Messages After a Redirect

If you’ve got an Action in Struts 1 that leaves an error or message for the view, it does it somewhere in the class like this: ActionMessages messages = getMessages(request); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.detail", "Normality has been restored.")); saveMessages(request, messages); However if your Action later selects an ActionForward that redirects (possibly unbeknownst to the Action, since [...]

WARNING: Form ‘myForm’ not found for locale ‘en_US’

It looks like someone had this error in 2006, and it was never resolved. I am posting this, hoping that in 2018 someone will have the same issue again, and the wisdom of the ancients will not fail him. Dec 10, 2012 1:41:05 AM org.apache.commons.validator.ValidatorResources getForm WARNING: Form ‘myFormBean’ not found for locale ‘en_US’ In [...]

Getting the last element in an array in JSF and JSTL

I’d love it if JSTL had some sort of way to get the last element in an array. Ruby conveniently makes negative indexes start from the end of the array: myarray[-1] For some reason, lists and arrays in Java have “.length” and “.size()” accessors, instead of either getLength() or getSize(), and there isn’t a convenience [...]

Selecting Rows from the Last 5 Years in SAS

I was asked recently in a Q&A, “how to select the last 5 years worth of data from a table in SAS?” One way of doing it is by selecting the data with a Proc SQL query similar to the following, and something similar could also be done in a data step: PROC SQL; create [...]

Two Common Struts Null Pointer Exceptions

The First Problem I have come across this problem at 2 times this weekend. Since I came across it twice, I assume a high likelihood that others will as well. Hopefully the people of the future will be able to Google the stack trace and find this post. The problem is that after mucking around [...]

How to write your own Custom SAS Functions

Since SAS 9.1.3 we’ve had the ability to write our own SAS call procedures and functions using PROC FCMP (short for “Function Compiler”). A simple example of this is as follows: proc fcmp outlib=work.funcs.temp; function findname(uri $) $200; length name $200; rc = metadata_getattr(uri,’Name’,name); return(name); endsub; run; After running this, we should have a custom [...]

Blackjack Dealer Odds

Below is a graph and table showing the exact odds of a dealer’s end-hand given his show card. One thing to keep in mind when playing: if the dealer is dealt a show-card of an ace and you’re being asked to hit or to stand, you know that his hole card is not a ten. [...]