WINTER 2011
TECHIE TIPS
User Profile: Jared Prins
User Tip: James Profitt
Read.
Have you changed companies? Do you want to modify your contact preferences? Don’t forget to update your SAS profile!

You can easily find out what's new in SAS 9.2 from new products to updates and enhancements.

Go to the SAS®9 link from our support.sas.com Web site.
For details on all of SAS' products and solutions, click here.
The SAScom blog: http://blogs.sas.com/sascom/
SAS Canada

SAS® USER PROFILE
Names: Jared Prins
Location: Edmonton, Alberta
Company: Government of Alberta, Parks Division
Personal Blog: jaredprins.com

SAS History (years using SAS, platforms, primary products, etc.): Six years SAS Base and Enterprise Guide, 2 Years SAS Text Miner.   

Pets: A cat that has me wrapped around her little paw.

Partner/Family: My wife of 7 years whom I cherish.  I love you honey!  You are always right!

Sports/Hobbies: Jogging and anything computer related such as computer games or Linux.  People think it’s weird, but I also like to read computer text books.  

Favorite foods: Those Dutch licorice salted candies. Yum.

What your ideal weekend would be:
What’s a weekend?  You mean people actually get time off Work?  I thought that was a myth.  Let’s see…a weekend where I can truly relax involves watching TV, playing video games, eating good food. 

If I could be anything at all (besides a SAS user), I would be: It’s a toss-up between a Linux programmer or a Gardener/Landscaper.

When I’m not using SAS: I’m probably playing Team Fortress 2.  For all you n00bs out there, I’ll pwn you.  Yeah you heard me…pwn3d, rick rolld, sux0rs to be you!

The funniest/strangest thing that’s ever happened to me in the SAS world: How about the fact I went from openly rejecting the very notion of learning SAS to using it all the time and prolifically blogging about it?  Or how about that my Mom told me to apply for a SAS job way back when I was in University and I didn’t listen to her?  Now here I am using SAS products 10 years later!

One thing every SAS programmer should know: (techie tip): Take the time to setup your SAS environment the way you like it.  For me, I like to double click on my computer shortcut to SAS and have all my references to projects, formats, output folders and datasets load. 

I used to work from multiple computer systems (I still do, but not as many) which all had different folders or drives where my files were.  Here is what I did:

1) Right click your shortcut to SAS.exe, and add the following switch:

-AUTOEXEC "E:\path\to\AUTOEXEC.SAS

That entire line should look like this:

"C:\Program Files\SAS\SASFoundation\9.2\sas.exe" -AUTOEXEC "E:\path\to\AUTOEXEC.SAS" -CONFIG "C:\Program Files\SAS\SASFoundation\9.2\nls\en\SASV9.CFG"

2) The magic is in the AutoExec.sas file.  Mine is such that I can easily work on any computer.

%global working_location;

%let cname_office = "Tardis";
%let cname_home = "TheDoctor";
%let cname_laptop = "Gallifrey";
%let cname_resource = "Dalek";
%let cname_server = "Cybermen";

%let cname = "%sysget(computername)";
%put "You are working at &cname.";

%macro environment_setup;
%put "Checking your location...";
%if ( &cname = &cname_office ) %then %do;
%let working_location = C:\path\to\files;
%put "Location determined: &cname";
%put "Setting up for office";
%goto exit;
%end;

%else %if ( &cname = &cname_home ) %then %do;
%let working_location = E:\path;
%put "...Location determined: &cname";
%put "Setting up for office";
%goto exit;
%end;

        %else %if ( &cname = &cname_laptop ) %then %do;
%let working_location = F:\files;
%put "...Location determined: &cname";
%put "Setting up for old office";
%goto exit;
%end;

%else %if ( &cname = &cname_resource ) %then %do;
%let working_location = R:\Shared\location;
%put "...Location determined: &cname";
%put "Setting up for work";  
%goto exit;
%end;

%else %if ( &cname = &cname_server ) %then %do;
%let working_location = D:\;
%put "...Location determined: &cname";
%put "Setting up for laptop";
%goto exit;
%end;

%else %do;      
%put "!!! ERROR with determining working location !!!";
%goto exit;
%end;

  
%exit:
%mend environment_setup;

%environment_setup;

%INCLUDE "&working_location\setup.sas";
%INCLUDE "&working_location\path\to\constants.sas";

3) Setup.sas is where I configure things like global options or other larger scope programming.  The vital piece is the constants.sas file. This is where I reference libnames, data sets, formats, macros and other project specific components. Once I double click my custom SAS shortcut, all of my projects I’ve ever worked on are accessible with consistent naming conventions. This makes it easy to code between datasets and to combine data from different projects.

My final piece of advice for programming is always ask yourself if the ends justify the means.  I know my code above could be improved, but to what end?  It works fine for me and is easily maintained.

 

SAS and all other SAS Institute Inc. product or service names are registered trademarks \or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are trademarks of their respective companies. Copyright © SAS Institute Inc. All rights reserved.