DATA Step, Macro, Functions and more

Could anyone help with the difference between if then and if % then?

Reply
New Contributor sww
New Contributor
Posts: 4

Could anyone help with the difference between if then and if % then?

Being confused with the difference between if then and if % then? Could anyone help? Thanks a lot!

Super User
Super User
Posts: 7,401

Re: Could anyone help with the difference between if then and if % then?

If <condition> then <code> is part of Base SAS

%if <condition> %then <code> is part of Macro Programming

 

Please refer to the documentation on what each of those products are and what they do, basically Base SAS is the programming language, Macro is an additional component to generate text code.

New Contributor sww
New Contributor
Posts: 4

Re: Could anyone help with the difference between if then and if % then?

Really appreciate, I am reading the Macro Programming based on your suggestion now.Smiley Happy

Super User
Posts: 10,500

Re: Could anyone help with the difference between if then and if % then?

Here is a very strong hint: If you are comparing dataset variable values use if/then/else.

If you are conditionally creating program code you likely are looking at %if/%then/%else.

Trusted Advisor
Posts: 1,115

Re: Could anyone help with the difference between if then and if % then?

Have you looked at the section "Comparisons" and Example 1 ("Contrasting the %IF-%THEN/%ELSE Statement with the IF-THEN/ELSE Statement") of the %IF-%THEN/%ELSE Statement documentation?

 

Or have you tried to use either of the two statements and it didn't work? If so, please feel free to report the specific problem you encountered. It's probably most helpful for you to get an explanation that is related to your own program code.

Ask a Question
Discussion stats
  • 4 replies
  • 221 views
  • 0 likes
  • 4 in conversation