SAS and Literals

There are three types of literals in SAS that are frequently used. They typically follow the format of being quoted and having a letter at the end.

Date Literal (d)

When hard coding in a date into your code or creating a date, you need to specify it in the DATE9. format, and add a d at the end. For example:

date_var = ’31Jan2016’d;

You aren’t required to put in a 4 year date, but I highly recommend it. Another way to reference a date without using a literal is to use the MDY function. 1,

x = MDY(1, 31, 2016);

With the dates specified in this format you can use it in your code, either assign it to a variable or use it for comparison. The following two lines of code will result in the same thing

if x=’31Jan2016’d then do;

if x=mdy(1, 31, 2016) then do;

Datetime Literal

Along those same lines, you can also specify a datetime variable in SAS, except this time you use the letters dt.

datetime_literal= ’31Jan2016:04:20:00’dt;

Again you can also use a function, in this case, its the DHMS() function.The first parameter in this case is date, followed by hour, minute and seconds.

datetime_function = dhms(’31Jan2016’d, 4, 20, 0);

Name Literal

The last one is more rare to see, because SAS usually doesn’t allow it. EG does have it allowed by default. SAS variable names have restrictions, such as no spaces and they cannot start with numbers. If you want to ignore those restrictions you can set the option validvarname. The default value is V7.

 

option validvarname=any;

With this option you can create a variable that has a name such as ‘My Variable’

To reference it, you then use the letter n to distinguish it from a character string.

‘My Variable Name’n

 

Trust in Data Science

Trust – a person on whom or thing on which one relies (Dictionary.com)

Data Science is a difficult field.

There isn’t always certainty in the answers, methods or recommendations. What works today may not work tomorrow or in a new field. A new algorithm speeds things up, new information changes the best method, best practices change. Staying on top of all of that is most definitely a challenge. Being a CEO, CIO, or even a Chief Data Scientist is a daunting task. Which is why the people who do the actual day to day work need to be trust worthy. As the CEO or a colleague, I need to trust that you know what you’re doing and that what you recommend is something I can go along with. I may not always be in a place to verify every detail of your work, or sometimes even understand it.

So if you’re a douchebag online, insult people online, make sexist remarks in the office at the water cooler or the corporate jet you can’t really be trusted in my opinion. In general, when you can’t trust someone you don’t trust the work they do.

So don’t be a douche bag. Online or in real life. Is that really so difficult?

Sample Work

SAS Presentations


Reporting from BASE SAS – Tips & Tricks (2011)

  • Indexes, Proc Means (Ways/Types), ODS Tagset Intro

Creating a TOC Using CSS (2011)

  • Creating a Table of Contents in Word document by styling text in standard Word formats and then using the auto format feature in Word.

Coordinating Complex Reports in SAS (2014)

Avoid Macros (2015)

  • FAQ for macro’s
    • Importing multiple files
    • Export multiple files
    • Splitting a SAS dataset
    • Calling Macro multiple times
  • Sample Code

Reports with Style from Excel

  • Examples of using ODS TAGSETS.EXCELXP features

Windows 7 and SAS 9.3

  • Highlight some new options available under Windows 7 and in SAS 9.3

Sample SAS code library on GitHub


Tableau

Who Benefits From Open Data

I’ve been involved in Open Data from late 2009 when Edmonton (#yeg) first started it’s Open Data initiative. Since then, I’ve participated in hackathons and MeetUps in both Surrey and Vancouver while living outside of Alberta. After moving back to Alberta, I’ve once again started to participate in the Open Data initiative within the City of Edmonton. While definitely in it’s infancy I believe this group does have a lot to offer to the citizens of Edmonton, and the current leadership appears motivated to get there. FYI, I’m involved, but not in a leadership role, I sit/listen/comment/criticize while others work.

Anyways, lately I’ve been thinking about this whole initiative and wondering who actually benefits from Open Data. And the answers I’ve come up with are below. Feel free to add your own in the comments.

1. Government
Open Data relies on the government first off organizing its data in a useable form, which is hard to believe many actually don’t always do. Being forced to organize the data is self-preservation for all the FOIP and accountability measures that are being brought up.
Government also benefits because it now has access to data from different Ministries and different levels of government (Federal, Municipal, Provincial) without having to jump through hoops that could have included signing data sharing agreements, memorandums of understanding that could sometimes take weeks if not years to hash out at a significant cost in terms of both employee and productivity.

2. Businesses
Releasing Open Data freely means not having to pay for access to data that once cost a bundle. Additionally, it also means that there is now data that they didn’t even know existed that they can use in conjunction with proprietary data to enhance business services.
Using Open Data isn’t as easy as downloading a data set most of the time, so there are also business opportunities for skilled analysts and companies that are willing to use these data products to provide new services to companies that need this information.

3. Citizens
In general, Open Data provides a benefit to every day citizens by providing access to information that would otherwise not be be available. But to be honest, knowing how much a government employee get’s paid, the demographics of my neighbourhood, or the type of tree in front of my house have a fairly limited benefit to my overall daily quality of life. The benefits of the data will come from how the government and business use the data.
There is currently a lot of movement around citizen engagement and citizens using the data to produce apps and new information, but is this a permanent movement or a temporary fad with the sudden access to information? Also, with citizens there is no incentive to continue to update these products save for general interest and for many people life has more demands than the data waiting on a website. Like my puppy that’s staring at me waiting for a walk.

Why I won’t jump in bed with Tableau as yet…

I’ve seen all the hoopla over Tableau over the past few years and even followed their stock over the past year. I’ll admit to having regret over not purchasing the stock.  They do have cool visualizations but I’m still hesitant to jump on the bandwagon.  Here are my three main reasons:

1. Difficult to distribute results

Getting results from my toolset to an audience is a key measure of its usefulness. If it’s too difficult and there are too many boundaries then people won’t use it and that alone makes it useless. Currently, the ways to distribute Tableau results appear to be through their public website, as a workbook on your own server, or a workbook on their server. There are limitations to all three, the if you go Public,  your data is now public and open to anyone, if you choose a workbook, your user needs to install reader and for the server, well money is one issue and then setting it up and administration, all another big headache.

2. GUI – Point and Click Interface

Though some people may find this a plus, I find this a drawback. I like the option of a GUI, but when it comes time to operationalize a visualization I can see the difficulties. Remembering exactly what buttons you clicked in what order 8 months ago to create a viz will be a pain in the ass. I can totally see a client coming in and saying, I want exactly what you did for such-and-such, but with my data. In Tableau, that implies recreating an entire workbook because you can’t copy and paste the code and need to relink all the fields.

Also, have you ever tried to explain a solution to a person for a GUI tool, first you click A, then hover over B, then Drag to C.  Its infinitely easier to provide solutions that are code.

3. Not Enterprise Ready

Tableau is a great tool, but I don’t feel they’re quite enterprise ready. I’ve tried to work with their mapping focus, and they don’t work with any of the industry standards for maps, SHP or TAB. The proposed solution is to use open source tools to hack your way through it. Its not impossible and I got it working, but I couldn’t do it on my work computer because no big corporation allows users to self install programs. The same with their recently released Excel add in to reshape data. Great idea, but I can’t install it because I don’t have install privileges.  And I wish I was alone in that, but that’s been the standard at most places I’ve worked at.

At the end of the day though, its still a toolset, you still need a person with the vision behind the data. To manipulate, twist and turn it until it tells its story.

My Tableau Viz:

http://public.tableausoftware.com/views/PercentofPop65over/Dashboard1

 

Howdy!

Hi All,

I’m a statistician living in Edmonton, AB, Canada and I’ll be blogging about statistics, methodology, programming, SAS and any random thing that comes to mind, including country music.

Please do feel free to comment because I definitely have an opinion, but it isn’t fact and I’m sometimes wrong. Not very often mind you 😉 Also, I’m curious as to how you find your way here.

Cheers!

@stat_geek