Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6697761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:29:55+00:00 2026-05-26T06:29:55+00:00

I have inherited a 37,000+ line SAS script, not including additional inherited modules. Given

  • 0

I have inherited a 37,000+ line SAS script, not including additional inherited modules. Given a beginner knowledge of SAS and a moderate knowledge of Python, I was wondering if this was considered excessive as it seems to me and recommendations on a way to layer and break apart a typical SAS script.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:29:56+00:00Added an answer on May 26, 2026 at 6:29 am

    This is a common issue with SAS, as many people who write SAS programs have a background in analysis and not efficient programming. The first thing that I would suggest is placing a block of the code within a macro definition, then testing calling the macro and ending the program with an ENDSAS statement before it executes the rest of the code. This will allow you to run diagnostics to determine what that block of code does. Once you understand what the code is doing, you can decide if you want to break this code up into further macro definitions to have each macro perform one logically cohesive set of instructions.

    Once into the program you might find similar code repeated, with a few differences such as a choice of parameters, data set names or variables. If you find this type of repetition, then you can probably design a macro that uses parameters to generalize the code. Afterward you can replace the repetitive instances with the macro call, changing the parameters as needed.

    Similarly, with that long of a script I would expect that you are going to find a place where inserting a DO loop will help add structure, whether that be within a macro definition or within a DATA step.

    Sometimes, though, a SAS program just requires that many lines of code. Breaking it up into logical steps with macro definitions will help its readability and maintenence, but it will do little to improve efficiency. In those cases, the least you should do is to write a comment section near the top that briefly describes the purpose of the program, then add comments throughout the code to explain what a particular block of code is doing.

    Here are two caveats for this technique, though. First, if the original program defines macro variables, then you might have an issue on the scope of these variables if you define them within a macro. Macro variables defined outside of a macro definition are global in scope; but unless you specify that they should be global, then macro variables defined within a macro definition (and macro parameters set when the macro is called) will be local and will not be available once the macro executes. A similar issue is that more than one macro variable can have the same name but their scope is different, which can result in unexpected values when they are returned. The second warning is that if you use a macro definition to comment out large blocks of code so that you can test later sections of the code in a different run, then make sure to save any necessary datasets to a permanent location; otherwise they will be deleted and not be available for the later testing.

    Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have inherited some code, the original author is not contactable and I would
I have inherited a single project in svn: 30Gb in over 300 000 files.
I have inherited a medium sized iOS project - ~30,000 lines of code -
I have inherited a client site which crashes every 3 or 4 days. It
I have inherited some legacy PHP code what was written back when it was
I have inherited an old crusty PHP application , and I'd like to refactor
I have inherited a VB6/Access application that we have developed and sold for many
I have inherited a poorly written web application that seems to have errors when
I have inherited a project that uses LLBLGen Pro for the DB layer. The
I have inherited a c# class 'Button' (which I can't change) which clashes with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.