User:Mbogelund

From sasCommunity

Jump to: navigation, search
< User:Mbogelund

Mbogelund's Blog

2009 March 06 09:52:36 EST
Posted By: Mbogelund
Discussion
Mbogelund's Blog

Introducing the Stack Overflow site to the SAS community

The good old SAS-L newsgroup and SAS support are excellent places to seek help for your everyday SAS programming challenges. And SASCommunity.net is a good supplement to these sources. Still I'd like to introduce the free programming Q & A site called Stack Overflow. Please take some time to look at Joel Spolskys introduction to Stack Overflow. Joel Spolsky is one of the people behind Stack Overflow.

"What's so great about yet another programming Q & A site? And why should SAS coders care?" you might ask. The three ingredients that make Stack overflow great are

  • Great reputation-, rating- and feedback-system
  • Not specific to any programming language
  • Backed by a great community

This means that you can ask SAS programming questions, JavaScript questions, SQL questions, HTML questions, ... and you have access to a lot of people who actually master these topics. Asking a MySQL specific question at a SAS specific forum might give you an answer, that might be helpful. It even might be the best possible answer. But since you posted your question to a group of SAS coders, you could still be sitting next to your computer, wondering if you could have gotten an even better answer by asking your question in a MySQL specific forum.

The voting system helps by enabling you to give a vote to answers you find helpful, and even to vote for good and interesting questions. And if you were the one asking the question, you can even flag the answer that you find is the best or correct one, so that any subsequent searches for that question will immediately show the best answer - Without having to read an endless line of chit-chat before getting to a posting that is helpful.

But that's not all. There are a lot of features that help making that site a really great tool for your coding questions - More than I care to mention here, you should go and check it out for yourself!

I've asked some SAS specific questions at Stack Overflow, and I actually got some good and useful answers, putting my expectation that I'd be the only SAS coder there, to shame.

I can definitely recommend Stack Overflow to all you SAS coders out there - and the more SAS coders we are at Stack Overflow, the better the SAS-answers will be. Access to Q & A related to other technologies and programming languages is also helpful, if you, like me, often involve non-SAS technology in your projects.

As long as you remember that only programming questions are allowed, you'll get a lot of help - so don't send support requests for a non-functioning monitor, don't ask for advice picking the best anti-virus utility, etc. Programming related questions only!

Go have a look! I promise you'll like it!

Blog Entry: User:Mbogelund/BlogEntry: 2009 March 06 09:52:36 EST

2008 November 28 09:29:37 EST
Posted By: Mbogelund
Discussion
Mbogelund's Blog

Designing condition reporting functionality, part I

As an application designer and programmer, I often find myself in a situation where I need to report on a certain condition, like an error, warning or note. Usually I do that by simply putting some text to the log, or adding information to a web page sent to the user:

rc=libname('data','/tmp/tmpdata');
if rc>0 then do;
   message=sysmsg();
   put "Some serious stuff went wrong here, man! You better check it out.";
   put "The system said that:" message;
end;

or

proc sql noprint;
  select count(*) into: rowcount
  from data.transactions
  ;
quit;

data _null_;
  file _WEBOUT;
  if input(symget('rowcount'),8.) = 0 then do;
     put "<div id="usermsg" class="warning">Oh my! Something might be wrong; we didn't load any transactions!</div>";
  end;
run;

(this is not real code I used here, I made it up as I went along to show the general concept. So don't get confused about syntax errors and such!)

After a couple of years as a SAS programmer, I have a bunch of these little condition reporting snippets of code floating around every system I've ever made. Then my boss might stop by and say something like "Hey, Martin, wouldn't it be great if we could react as soon as an error happens in our applications - like having it sending us an email or broadcasting a syndication feed item?" I'll answer "Well, yeah, pretty cool idea boss!" while I try to smile - I'm thinking of the thousands of systems I made, containing millions of these little if ERROR then put SOME-WARNING-TEXT I've crafted over the years. Boy, am I in trouble now...

So, I was thinking... Why don't I stay ahead of events, and implement some kind of "condition reporting functionality", or what ever you could call this baby - a set of data and macro functions that enable me to

  • dump a condition code into a data table, possibly along with some parameters, like libname, return code, and the system error message
  • call a function that matches the condition code with one or more messages (eg a technical error message to the developer, and a more user oriented one for the user)
  • have the function report the messages through some centralized, target-specific channels (email, HTML, syndication feed, ...)

Then, if my boss comes along and starts talking about how it could be cool if he could get an alert on his Blackberry every time a user hits an error(!), I could say "Sure thing, boss! Give me an hour!", and then run a data step that made a boss-oriented message for each error-condition, update my function - my single, centralized function - to send the boss-oriented message to his Blackberry (and then play online poker for the remaining 40 minutes, before I report the solution is ready ;-)

So, how to design this thing? Until now I've figured that I will need

  • a CONDITIONS data table, defining all valid condition codes along with some descriptive text
  • a MESSAGES data table to hold the messages and parameters that go into the messages
  • a CHANNELS data table, defining where to send the messages (back to the user, log-file, error data set, mail to developer, alert on Blackberry, etc)
  • a CONDITIONS-MESSAGES-CHANNELS relationship data table that maps conditions to messages and channels

But am I re-inventing the wheel here? Have you made a cooler, smarter or more general solution to address this issue, or if you have some brilliant input or ideas how to do this, I'd surely like to hear about it!

Oh, and by the way, my boss isn't like that at all...

Stay tuned for more on this subject!

Blog Entry: User:Mbogelund/BlogEntry: 2008 November 28 09:29:37 EST

Views
Personal tools
Toolbox