tag:blogger.com,1999:blog-106293752008-10-08T13:35:05.987-07:00Data StepsA regularly updated blog about programming with the SAS System.Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comBlogger68125tag:blogger.com,1999:blog-10629375.post-82393524339090264372008-08-21T10:20:00.001-07:002008-08-21T10:54:30.489-07:00Thanks San DiegoThank you to everybody at the San Diego SAS User's Group. I had a great time meeting everyone and presenting. The paper and code can be found on my site at: http://www.pelicanprogramming.com/sgf08/sgf08.html I will also put the power point up when I get a chance. Thanks again for hosting me as a speaker! And thanks to Kirk Paul Lafler of Software Intelligence Corp for letting me use your Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-83399602758743799812008-08-06T15:03:00.000-07:002008-08-06T15:14:39.684-07:00A Great Blog From A SAS UserI just checked out Ann Maria's Blog from the Julia Group and was so impressed with her writing that I had to share it. I particulary liked The Dangers and Wonders of Statistics Using SAS post. Go check it out. Now.Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-41283932753257743732008-07-30T16:18:00.000-07:002008-07-30T16:24:54.964-07:00JavaScript Object NotationI use Javascript quite a bit for my i-Doc site and some of the projects I work on. I really like the language because it's syntax is comfortable and you can do a bunch with it without having to know a lot about it. And getting stuff done quickly is pretty much the whole reason for programming. But the "looseness" of Javascript can also tempt you to fall into programming habits that don't scale Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-10722364593909017922008-07-24T11:30:00.000-07:002008-07-24T11:40:18.329-07:00SAS Macro NestingI'd like to share a nifty SAS option that will help tremendously with debugging SAS macros. The mprintNest system option will show nesting information in your log. This is a big improvement over mprint that showed which macro you were in, but made it nearly impossible to tell which macros may have contained the macro call. With mprintNest you can see exactly where you are in the executing Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-73021231079021696252008-06-04T15:29:00.000-07:002008-07-03T11:34:29.380-07:00Data Set Sorted By Information#UPDATE# Please see the comments for a better way to get the sorted by information from a data set! #UPDATE# The other day a colleague mentioned that it was not possible to get the sort information for a data set from the dictionary tables. Intrigued, I took up the challenge. While it's true that you cannot get the sorted by information directly, it is possible to get the necessary informationStephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-71723377050085843242008-05-09T14:46:00.000-07:002008-05-09T14:57:08.748-07:00i-Doc Interactive SAS DocumentationAfter much hard work, I am happy to announce the arrival of i-Doc interactive SAS documentation. The idea behind i-Doc is to generate SAS documentation from users all over the world. I have started with SAS functions and hope to continue with formats, informats, macro, system options, etc. Eventually I'd like to provide copies in book format for people to keep on their desks. Please check it Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-81645815385658532682008-04-17T14:51:00.000-07:002008-04-17T15:02:53.928-07:00SAS SQL JoinOne of the most frequent uses of SQL is to join tables. And since SAS data sets are tables, there is good reason to learn SQL. But a lot of SAS programmers will shy away from learning SQL because they are already familiar with merging in the data step. Here are three additional reasons to use a SQL join instead of a data step merge. But first two little sample data sets to use for the examplesStephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-82772376308363590982008-03-26T10:36:00.000-07:002008-04-16T10:43:50.346-07:00The Cats() FunctionOne of my favorite new functions is the cats() function available in SAS v9. It is a compress() like function in that it removes leading and trailing blanks, but it also concatenates the results. CATS() stands for concatenate and strip. Basically the cats() function takes this type of assignment statement: key = trim(left(firstName)) || trim(left(lastName)) || trim(left(phone)) || Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-37640767203307853562008-03-18T12:47:00.000-07:002008-03-18T12:58:53.695-07:00Blogging At the SAS Global ForumSo far so good at The SAS Global Forum. I haven't had too much time to go to a lot of talks, but I attended a really informative one yesterday morning. Judy Loren from Health Dialog Analytic Solutions gave a good talk on using data step hash objects. One little code tidbit that caught my eye was this loop construct: do i = 1 by 1 until( some criteria or i > 1000 ); It is a nice shorthand Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-20964834166029039702008-03-13T14:37:00.000-07:002008-03-13T14:55:49.844-07:00SAS Global Forum 2008 Howdy Ya'll! I will be travelling to San Antonio, TX for SAS Global Forum 2008. I am not really there to "blog" the conference, but I will do my best to take some pictures and share my thoughts on different things I see there. Mostly I plan on wandering around, getting some free swag, meeting as many people as I can and having a good time. Oh, and I am presenting a paper "SAS Macros: Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-77375731499472349502008-02-07T14:53:00.000-08:002008-02-07T14:59:54.895-08:00Excel Text WrapI often work with data sets that have large text columns. Invariably, the long text fields almost always are related to customer complaint data. It seems we are at our most eloquent when we have something to complain about! Anyways, I often end up pushing these data sets with large text columns into Excel. And Excel takes the text column and sizes it to only show some of the text. To remedy Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-55036766859822874732008-01-29T11:22:00.000-08:002008-01-29T11:31:23.160-08:00New Macro IN OperatorHas anyone gotten the new IN Macro operator to work? I just want to test it out and SAS Macro keeps coughing up an error that a character operand is found where a numeric operand is required. According to the documentation, you can use the # character or the mnenomic IN. Their example is A#B C D E. I am trying to test it with: %macro test; %if A#B C D E A %then %put it works; %mend test; %Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-14983823639147150132007-11-14T11:34:00.000-08:002007-11-14T11:43:07.936-08:00Using Logical Expressions In SQLMost of us SAS programmers approach SQL as simply a data extraction and table joining tool. Since most of us have used the data step longer than SQL, we tend to leave the logic programming to the data step with its if/then statements. However, SQL does have a way of assigning values conditionally. With the CASE expression you can test and assign values logically. The basic syntax is: CASE Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-82226055420741252002007-10-16T11:43:00.000-07:002007-10-16T15:15:48.506-07:00Saving Steps With SQLOften we need to create some simple statistics for a set of data and then associate those stats with each observation of the original set. As a simple example consider a table with only three rows: N 3 6 4 We want to get the mean of the variable N and stripe it down all the observations: N Mean 3 4.333 6 4.333 4 4.333 The first way I learned to do this was with a proc summary and a merge. A Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-63521640975174142392007-09-19T17:07:00.000-07:002007-09-19T17:12:23.459-07:00Hooray For Vmware!I am excited for computers again! Every once in a while something comes along that really changes the way you interact with computers. You know the feeling, it stops you in your tracks and makes you say, wow. I remember when I was a kid and I first played a game called "Beach Head" on my Commodore 64. There was a level where you controlled a machine gun and the little computer guys would run Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-90930057814737776492007-09-13T11:06:00.000-07:002007-09-13T11:07:06.398-07:00Bootstrap ResamplingFirst of all, I should mention here and now at the beginning of this post that I am not a statistician. But I am married to one (Happy Bithday Orla!), and I dounderstand normal distributions and confidence intervals and standard deviations and such. Suffice it to say, I generally get the concepts but my eyes invariably glaze over once the equations are presented. Now that I've gotten that out Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-65628758059986961672007-08-21T14:48:00.001-07:002007-08-22T11:34:20.809-07:00Clean Up Clean UpClean up. Clean up. Everybody everwhere. Clean up. Clean up. Everybody do your share. This is the song my wife taught our two-year old daughter in the hopes that it would make clean-up fun and encourage more of it. Sometimes it works really well and sometimes not so well. Every now and then it backfires completely and my toddler makes a big mess just so she can run around in circles singing Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-73002321857365767412007-08-07T11:21:00.000-07:002007-08-07T11:27:11.831-07:00Multiple By VariablesHere is one little piece of SAS programming that I always have to work out: When using multiple "by variables" in a SAS data step, when does the grouping flip? An example: data stuff; set otherStuff; by var1 var2 var3; if first.var1 then ...; if first.var3 then ...; run; For some reason, I always have to sit and think through how multiple by variables effect each other. So here,Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-38035283670932072822007-08-01T09:42:00.000-07:002007-08-01T10:36:39.655-07:00Summer ReadingCurrently I am reading a book that is so good, I thought I would give it a quick recommendation. Against The Gods: The Remarkable Story of Risk is one of those books that I know-- before even finishing it, I will read again, and again. And I will gain deeper insights into history, humanity, stock markets, statistics and even the decisions that I make in my everyday life. So if you get the Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-393549293824256582007-06-13T09:03:00.000-07:002007-06-13T09:22:44.565-07:00Los Angeles Basin SAS User GroupIf you live in the Los Angeles area and have not had the chance to attend a LABSUG you are missing out. Kimberly Lebouton has worked very hard to bring a user group to Los Angeles and her efforts have been very productive. The speakers have been very good and Kimberly has worked diligently to listen and respond to attendee's feedback. I was hoping to attend this year, but my wife is going out Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-1752858569228218122007-05-29T13:42:00.000-07:002007-05-29T13:53:33.224-07:00Where Did the Observation Come From?Here is a little snippet of code I created to address the problem of assigning a value to a variable based on what data set an observation came from in a data step. Here is an example: Suppose I have a whole bunch of data sets each representing a different country. I want to set a lot of them in one data step and create one resulting data set with a variable called language. In order to create Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-49906599687825678882007-05-23T14:05:00.000-07:002007-05-23T14:24:29.503-07:00Saving TimeWhen I was a kid my brother, sister and I spent a lot of time in my Father's dental lab. This gave us a unique opportunity to learn how to get things done in a time-sensitive production environment. The more business he got and the more successful his practice became, the more demanding his labwork. He spent a lot of time working in the lab perfecting techniques and efficiency. We kids would hangStephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-75480571937557675522007-05-17T14:22:00.000-07:002007-05-23T14:24:12.804-07:00LRECLHere is a SAS trick that is especially useful for Windows users. By default, Windows creates files with a logical record length of 256. This means if you are creating a flat file with records (lines) longer than 256, the lines are going to wrap. You can tell Windows exactly how long to make the record length on the filename statement in SAS. The option is lrecl= (logical record length) and it Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-41273242849610054142007-03-28T13:41:00.000-07:002007-03-28T14:11:39.802-07:00SAS Programming Google SearchI have added a custom SAS programming search button to the top of this blog. It is done through Google Co-op and should offer better SAS programming search results than just searching the web. You can use it directly from this blog, or you can add it to your Google homepage. To add it to your Google homepage click on the button "Add To Google". I have not added/filtered many sites in it yet,Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.comtag:blogger.com,1999:blog-10629375.post-28743806281310600292007-03-22T10:30:00.000-07:002007-03-22T11:57:07.479-07:00Not EqualA long long time ago (or what seems like a long time ago!), before I could could call myself a professional SAS programmer I made lots of little mistakes in my programs. Now that I have been programming for a long time and have lots of good habits, I generally tend to avoid the little mistakes. Now when I make a mistake it is generally one of the bigger varieties. :) One of the little Stephenhttp://www.blogger.com/profile/01356803756509162192noreply@blogger.com