Say I have the following data:
Var1 Var2 Var3
0 0 1
1 1 3
0 1 1
0 0 1
1 1 1
How can I change values in Var3 to "-999" if Var1=1 and Var2=1?
Yes, it's quite easy in EG. Create a new query, and create an advanced expression. In the advanced expression, the CASE function will let you implement "if then else" type logic.
You would want to use if-else conditions. Note that the -999 will be numeric since I assume that is what you want.
data want;
set have;
if Var1=1 and Var2=1 then Var3 = -999;
run;
Source:
Thanks, I understand the SAS base code that can do that, but since it's in Enterprise Guide, does it not have a point-and-click solution to it?
Yes, it's quite easy in EG. Create a new query, and create an advanced expression. In the advanced expression, the CASE function will let you implement "if then else" type logic.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.