Performing the Same Action for a Series of Variables
Using a Series of IF-THEN Statements
In the data set MYLIB.ATTRACTIONS,
the variables Museums, Galleries, and Other contain missing values
when the tour does not feature that type of attraction. To change
the missing values to 0, you can write a series of IF-THEN statements
with assignment statements, as the following program illustrates:
/* same action for different variables */ data changes; set mylib.attractions;if Museums = . then Museums = 0;
if Galleries = . then Galleries = 0;
if Other = . then Other = 0;
run;
The pattern of action is the same in the three IF-THEN statements. Only the variable name is different. To make the program easier to read, you can write SAS statements that ...
Get Step-by-Step Programming with Base SAS 9.4 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.