SAS – Access to Software

If you’re learning to use SAS, whether at school or home, having access to the software on your own is a benefit. SAS has three different methods that you can use to access their Base software for free. This includes access to the SAS Base + SAS/STAT + SAS/IML for free. Some of the Time Series procedures are not available. I’m not sure why the Time Series procedures are in their own package and not part of SAS/STAT.

The three different methods to access SAS for free are:

SAS University Edition – via download
SAS University Edition – via AWS
SAS Academics on Demand

Regardless of which method you choose, you will be interacting with SAS via SAS Studio which is a web based method of interacting with SAS. The browser is used to send commands to a server which sends the results back to your computer. In the downloaded version, the server is set up ‘virtually’ on a virtual machine on your computer. In AWS and AoD, the server is either on Amazon’s server or SAS’s servers. AWS can incur a charge, and will after 1 year after your initial set up. This is an Amazon restriction, free useage of their micro tier for 1 year. The charge estimates for Canada were approximately $8.64 a month
if the server was kept running 24/7. If you remember to suspend the instance when not using the charge will be less.  Other charges can be incurred if you transfer large data sets to AWS. AoD and SAS UE on desktop have no charge.

SAS UE that runs on your desktop ensures your data stays locally. However, if you work on
a multitude of computers, ie work, home, school and want access to your programs and data anywhere a cloud solution is your best option.

You have more control over the SAS on your computer, as you can set the RAM and make sure your computer is not working on anything else, if required. Your files are always available as text files on your desktop.

SAS provides some basic support for all of these versions via and

Disclosure: This post was not paid for and nor did I receive any benefits from SAS from posting.

Fun with functions

I’ve been programming with SAS for over a decade now, and am a very active user on the community. Partly because there’s so much to know. Today alone I learned two new function that I didn’t know or had forgotten :).

  1. NLITERAL() function
    • SAS allows you to name variables freely with the validvarname=any option. However this means you need to refer the variable with quotes around the name and a n at the end to differentiate it from a character string, i.e. ‘Variable Name’n.  Formatting a macro variable in this structure can be cumbersome as you need a quote, concatenate and a trim function to ensure that spaces are removed.  Then you need to make sure the quotes don’t interfere in your code and resolve properly.  The NLITERAL function takes care of all of this by properly defining it as a literal, and it’s smart enough to only do it when required!
  2. CHAR() function
    • The char function allows you to isolate characters in a string. When you need to loop over a string this is incredibly useful.
  3. UPPER() vs %UPCASE() function
    • I’m familiar with this function, but what I didn’t know was that if you use it when querying a dictionary table in SAS, it slows things down, so instead you should use the %UPCASE() function.

Another day, another piece of SASsy knowledge.

How do I write a macro to…split my data set into multiple files?

A very common question on forums and help boards appears to be “How do I write a macro to do XYX?”. Often times a macro isn’t required. This is part one of an ongoing series into how to accomplish a task WITHOUT using a macro.

The first example answers the question of how to Split a data set into multiple files. Any file generated using a file statement can be generated using this method. I will be using the FILEVAR option of a file statement to split the SASHELP.CARS data set into multiple text files, one for each Make. The process and code is below, hope you find it helpful!

This is a two step process:

  1. Sort the file
  2. Generate the output using a Data Step

BY make;


SET cars; *Dataset to be exported;
BY make; *Variable that file is to be split on;

*Create path to file that is to be exported;
if first.make then out_file=cats(‘/folders/myfolders/’, trim(make));

file temp filevar=out_file dlm=’,’ dsd;

*If first value of make then output column names;
if first.make then
put ‘Make, Model, MPG_HIGHWAY, MPG_CITY’;

*Output variables;
put make model mpg_highway mpg_city;


Getting Data Into Excel from SAS

Proc Export vs Tagsets.ExcelXP

Here’s a quick rundown of some of the relevant differences:

Proc Export

  • Native Excel file
  • Fast(er)
  • Multiple worksheets, one file
  • One dataset per Sheet
  • No formats
  • No graphics


  • XML File, not XLSX
  • Slower than export
  • Multiple worksheets
  • Multiple output per sheet
  • Formatted output
  • Titles/Text embedded

Since Proc Export is well documented and varies significantly between systems, I won’t go into that here.

For Tagsets.ExcelXP I highly recommend the following paper as a reference. It indexes the majority of the Tagsets.ExcelXP features and provides the appropriate page reference in the relevant paper. If you’re having issues with Tagsets.ExcelXP this is the best reference to answer your question.

Another common response to Tagsets.ExcelXP questions, where something isn’t work as expected, is that the latest version of Tagsets.ExcelXP is not installed. To download the current version, see here:

Pseudocode AKA Stop and Think

From Wikipedia:

Pseudocode is an informal high-level description of the operating principle of a computer program or other algorithm.  It uses the structural conventions of a programming language, but is intended for human reading rather than machine reading.

My definition:

A way to force you to think through your program before coding.  Really thinking through what variables you’ll need, what outputs you’ll need. It helps further on with the design. It allows me to work through some of the decision points that I’ll need to program later on, such as:

  • Should I use a macro variable or by groups?
  • Do I need to keep around the results from every simulation or just the end results? Which results do I need?
  • Where do I need counters?
  • Do I need break logic or define my loop with a do while instead?

This is an ideal situation, and I admit I don’t do it all the time. Sometimes experience allows me to skip this step, and sometimes I think experience allows me to skip this step and I shouldn’t.  There are many times, when I wish I hadn’t.

But basically, its a step that says, STOP AND THINK. Because thinking before doing makes things go faster. It’s also a great way to create a program structure that you can then pass on to someone else to actually code, if that’s an option.

What I’ve Learned From Being a Consultant

Things I’ve learned from being a consultant

Working from the government pays the bills, consulting on the side pays for toys :).


I’m the only working on this project, so you’d think you can organize it any way I’d want, right? No. At any time the client can ask for anything, including the full code and it is my belief if they’ve paid for it then they should get it. The code is mine, but was developed for them so they can have it. Maintaining code isn’t very much fun so I don’t worry too much about putting myself out of a job.

Time Management

Clients want things with a quick turnaround. Sometimes this means doing things at lunch time or spending time after work. When its my own time and means less tv or vacation time, it gets spent wisely. Also, see Organization. Being organized saves me and the client time. The time taken to organize things is probably equivalent to billing for time spend search for things.

Communication Skills

Rarely does a client ask for what they end up with the first time around, unless its repeat such and such for me.  This means working with clients to flesh out questions. If you get it wrong, then you waste time and that time gets billed to the client.  People generally don’t like paying for work that wasn’t what they requested. Especially, since I’m sure what they said was clear in their mind. Communication isn’t only listening to what a person says, its hearing what they want and sometimes that isn’t said.

Different Tool Sets

If a client uses SPSS, SAS, or R, then that’s what you’re working with on this project.  It’s good to know at least the basics in a few languages and how to look up things in those languages as well.


If I can generate the results on time, on budget that’s great. If those results are copy and paste insert into the manuscript/PDF/powerpoint presentation that’s 10 times better.  I’ll admit some of the designs would never had occurred to me, but come from clients requests.  However, seeing something once I can learn and adapt that design to other uses.

Logistic Regression – Quick Tips

When doing Logistic regression in SAS there are several procedures that you can use:

  • Proc Logistic
  • Proc Genmod
  • Proc Surveylogistic
  1. If you’re using survey weights then you need to use SurveyLogistic to have your variance and confidence intervals calculated appropriately.
  2. For categorical variables, use a CLASS statement and specify PARAM=REF to use referential coding. If you use EFFECT coding (the default option) then your p-values may not align with your odds ratio confidence intervals.
  3. Use the ODDSRATIO statement to get odds ratio for specific variables or to compare different levels.
  4. /EXPB after your model statement will allow you to have the ratios included in your output.
  5. Check the event selection that is modelled in SAS. By default SAS models the event Y=0, when you usually want Y=1. You can modify by specifying the event in your model statement.

So that are some quick heads up regarding using proc logistic in SAS.