BookmarkSubscribeRSS Feed
sww
Calcite | Level 5 sww
Calcite | Level 5

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

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

sww
Calcite | Level 5 sww
Calcite | Level 5

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

ballardw
Super User

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.

FreelanceReinh
Jade | Level 19

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 785 views
  • 0 likes
  • 4 in conversation