BookmarkSubscribeRSS Feed
tomcmacdonald
Quartz | Level 8

I've inherited a 3500 line SAS program that existed in a mainframe environment that I have refactor for a UNIX environment.  The code is a mess to put it lightly.  Are there any tips or tricks for dealing with this situation in the SAS world?  Thank you for any help. 

5 REPLIES 5
Jagadishkatam
Amethyst | Level 16
if it of graph then the below link could be of some help

http://support.sas.com/kb/52/964.html
Thanks,
Jag
ballardw
Super User

None of this will actuall "fix" anything but may provide a guideline for finding out what the program uses.

 

My first step on something like this is to apply a consistent code layout: indentation for instance especially on multilevel IF/then/else or Do /end blocks of code.

 

I like to have any external file references such as Libname and Filename statements at the top of the code then any custom format (Proc Format) at the top of my code even if not used until well into the body.

If there are any macros involved then have those together near the beginning of the program.

 

Within data step blocks it may be helpful to group all the declarative statements such as Informat, Format, Label, Attrib, Length, Array together near the start of a datastep. Add Label statements for as many variables as practical once you identify the purpose/use of a variable.

Look very closely for use of the :

Data thisdatasetname;

   set thisdatasetname;

 

structure. It is not uncommon for some programers to such just to add a single or few variables. If that is the case move the calculation to a previous data step. I had one project using this single approach removed 15 datastep calls.

 

If you find long blocks of if/then statements to do recoding it may be worth time considering use of custom formats/informats to move the logic into a different procedure.

 

Do you actually have GOTO or LINK statements involved?

 

I also tend to segregate the data manipulation parts, Data step and Proc Sql as much as  practical from any final report output.

SASKiwi
PROC Star

I don't think there is any silver bullet for this type of programming. Just tidying up the layout so it becomes more readable would be where I would start. Then it will become clearer where further improvements can be made.

ChrisNZ
Tourmaline | Level 20

Also, i like to draw a diagram of all the data set names as they are used in the program and see which table is used where as the code progresses.

LinusH
Tourmaline | Level 20
Sometimes it's better to get a fresh restart. Get bold of business requirements and major logical building blocks, then write the code from start, using the old stuff as reference and of course comparing data output.
Data never sleeps

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1060 views
  • 7 likes
  • 6 in conversation