BookmarkSubscribeRSS Feed
swathi123
Obsidian | Level 7

Hi I am new to sas and I am eager to learn and understand unknown codes.. As a beginner, how do I understand a complex sas code.. Whenever I see a big code, I panic. Any suggestions?

Have same problem wih understanding macro code. Complex macro code too.. How do i understand..

4 REPLIES 4
Cynthia_sas
SAS Super FREQ

Hi:

  Every SAS statement starts with a keyword, such as

OPTIONS or DATA or PROC or IF or SET or INFILE or LIBNAME or....you may see a function call in an assignment statement like:

newvar=sum(oldvar1,oldvar2); and in this case, SUM is the name of the function

  Searching in the documentation for the keyword that starts your statement should give you a general idea of what the statement does. Or searching for the SUM function will give you an idea and examples of using the SUM function.  If you have a procedure step: PROC xyz, then you can search in the documentation for PROC xyz to see the documentation topic that explains what the procedure does.

  I do not generally recommend working with the SAS Macro Facility until you understand SAS programming. I do not know what you mean by "complex macro code". The macro facility is only generating "regular" SAS programming code. It will be hard to understand what the macro facility is doing if you do not understand the underlying SAS code that is being generated.

  We have some classes that might be useful to you:

Programming1 (SAS Training in the U.S. -- SAS Programming 1: Essentials) would be the class for your first question and

Programming2 (SAS Training in the U.S. -- SAS Programming 2: Data Manipulation Techniques) would also be the class for your first question;

Macro Language 1(SAS Training in the U.S. -- SAS Macro Language 1: Essentials) would be the class for your second question and, not surprisingly, we recommend that you understand the concepts in Programming 1 and Programming 2 before you take the Macro class.

  And, if you are working with the SAS BI Platform, as some of your other questions seem to imply, then you will probably want to read the documentation for those products/components, too.

cynthia

complex
Calcite | Level 5
I can offer an interpretation of the authors question since i too am up against what i believe to be a similar problem.   I have a 3,000 line SAS program to "decipher" with macro code, macro variables and many base SAS statements.  Is there an easy way to "strip" away the codes intimidating complexity in such a manner that by doing so enables better comprehension of the codes "flow". Similar to an initial "big picture" expo that zooms toward the "little picture".  Thank you.
complex
Calcite | Level 5

I can offer an interpretation of the authors question since i too am up against what i believe to be a similar problem.   I have a 3,000 line SAS program to "decipher" with macro code, macro variables and many base SAS statements.  Is there an easy way to "strip" away the codes intimidating complexity in such a manner that by doing so enables better comprehension of the codes "flow". Similar to an initial "big picture" expo that zooms toward the "little picture".  Thank you.

Tom
Super User Tom
Super User

@complex wrote:

I can offer an interpretation of the authors question since i too am up against what i believe to be a similar problem.   I have a 3,000 line SAS program to "decipher" with macro code, macro variables and many base SAS statements.  Is there an easy way to "strip" away the codes intimidating complexity in such a manner that by doing so enables better comprehension of the codes "flow". Similar to an initial "big picture" expo that zooms toward the "little picture".  Thank you.


First run the program with the MPRINT option turned on.  This will show you the lines of SAS code that the macro generated.

 

If you really want to understand what the macro statements are doing on their way to generating that SAS code you might also want to turn on the SYMBOLGEN and/or MLOGIC options.  But if the macro is at all complex that can lead to a very clutter SAS log, so use that as a step of last resort.

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
  • 4 replies
  • 3255 views
  • 1 like
  • 4 in conversation