PC SAS Programmer Facing UNIX? SAS Enterprise Guide to the Rescue

This post was kindly contributed by Business Intelligence Notes for SAS® BI Users - go there to comment and to read the full post.

Time for another confession.  For more than a decade I have been running SAS jobs on UNIX servers, but I don’t really know any UNIX editors.  Not Emacs.  Not vi.  I could work around this without SAS Enterprise Guide, but it was painful sometimes.  Now that I have started using Enterprise Guide, it is *so* much easier to use a Windows PC to write code that will be stored and executed on a remote server.

The Dark Ages (Before Enterprise Guide)

I have worked a lot of places where we had both PC SAS and UNIX SAS.  People tended to use PC SAS by default, but if a program ran on biggish data, or needed to be scheduled, we would run it on a server.  Most people were more comfortable developing code on a PC in Display Manager SAS.  When writing code that would run on a server, often the process was something like:

  1. Develop SAS program in DM SAS.
  2. FTP the program to the UNIX server.
  3. Open a terminal window on the server and batch submit the program.
  4. FTP the log file back to Windows.
  5. Review log file on Windows, debug, goto #1.

Depending on the tools available at a particular site (Samba, WinSCP, UltraEdit, etc), the process might be a bit easier, but it was usually enough of a hassle to run jobs on the server, that most people stuck to PC SAS as much as they could.  Of course there were always one or two UNIX-philes in a group who shunned Windows, lived on the UNIX server, and would laugh at the ridiculous gymnastics most of us went through as they wrote, ran, and debugged their code purely on UNIX, using their favorite insanely customizable ‘nix editor.

Enterprise Guide Enlightenment

Enterprise Guide makes all this cross-platform work easier because Enterprise Guide does not care where your code is stored.  You can write a program, save the .sas file to a remote UNIX server, run the program on the remote server, review the log, and debug, all from an Enterprise Guide session running on your PC.  (More impressively, even if you choose to store your .sas files only on your PC, you can still use Enterprise Guide to execute the code on a remote server.)

Here is a process flow with links to two .sas files: 

EGunixImg1

 

Where are the actual .sas files stored?  Enterprise Guide doesn’t care.  They could be on my PC.  They could be on a remote server.  It doesn’t matter.  They are just links.  Want to edit a .sas file sitting on a remote server? Use Enterprise Guide.  Want to create a new .sas file and save it to a remote sever? Use Enterprise Guide. 

Because this post is about creating and editing .sas files on UNIX, these files are on a UNIX server.  Here is a listing of the files in /home/…/Demo/EGunix/Code:

sas enterprise guide putty

 

Using Enterprise Guide to Create a .sas File on UNIX

Using Enterprise Guide to create a SAS program and save it to a server is straight-forward:

  1. Open Enterprise Guide
  2. File->New Program
  3. Write program
  4. Save As and indicate it will be saved to the server

Starting with the process flow above, let’s create a third program, MakePlot.sas, and save it in the same directory on the UNIX server.  Picking up at step 4, I have written the program, and just hit Save As.  The dialog box looks as below: 

sas enterprise guide unix servers

 

To save the file on the UNIX server, first click Servers, and a list of available servers will appear.  The server named SASApp is my UNIX server.  Double clicking it will open your home directory, and then you can navigate down to the directory of interest.  Below you see I have clicked my way down to /home/…/Demo/EGunix/Code, and can see the two .sas files that are already in the directory.

sas enterprise guide with unix 

Enter a name for the program, MakePlot.sas, hit save, and that’s it.  The code was just saved to the UNIX server.  And a link to MakePlot.sas was added to the process flow.  You can even use the SAVE dialog box to create and rename directories on the server.   

Here is a terminal window showing MakePlot.sas is now sitting on the server.

EGunixImg5

 

One side note: When I first tried navigating the UNIX directory structure from Enterprise Guide, I couldn’t access any directories that were outside of my /home directory.  Then I found a great tip on Angela Hall’s blog.  On the UNIX side, create a symbolic link which links from your /home directory to the desired directory.  That link will then show up as a folder in Enterprise Guide’s SAVE dialog box, and allow you to access the desired directory.

Using Enterprise Guide to Edit a .sas File on UNIX

Editing code is just as easy.  The File->Open Program dialog box allows you to navigate the remote directory structure, the same way as the SAVE dialog box.  When you open the program, a link to it is added to your process flow.  After that point, to edit the program, just double-click the link.

Executing Code on Unix

To execute the code, just hit run.  Assuming your Enterprise Guide session is connected to the UNIX SAS Server, the code runs there. 

Uhmm, Why?

At this point (perhaps earlier), a reasonable question would be, “Since Enterprise Guide allows you to store code on your local PC and execute it on a remote [UNIX] server, why would you want to save the .sas files on the server?”  Truth is, if you want to use Enterprise Guide for all of your work, it doesn’t matter where you save the code.  But if you want to run the code as part of BI applications (stored processes, DI jobs, etc.), the code needs to be accessible to the server.  Also, sometimes I like to open a terminal window and do an old-fashioned batch submit, perhaps even schedule a batch job using the UNIX cron scheduler.  And every once in a while, a UNIX-phile might ask me for help with SAS code.  Instead of reading their code in a terminal window, I can open Enterprise Guide, and have all the benefits of a GUI development environment (more on that to come in my next post…)

Share Your Tips!

My last post about Enterprise Guide process flows paid off for me in receiving a number of great tips from readers.  Do you use Enterprise Guide to create/edit .sas files on a remote server?  Please drop a note in the comments with any hot tips!

The post PC SAS Programmer Facing UNIX? SAS Enterprise Guide to the Rescue appeared first on Business Intelligence Notes for SAS® BI Users. Written by .

This post was kindly contributed by Business Intelligence Notes for SAS® BI Users - go there to comment and to read the full post.