BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KubiK888
Calcite | Level 5

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?

1 ACCEPTED SOLUTION

Accepted Solutions
TomKari
Onyx | Level 15

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.

 

 

View solution in original post

3 REPLIES 3
Rwon
Obsidian | Level 7

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:

https://v8doc.sas.com/sashtml/lgref/z0202239.htm

KubiK888
Calcite | Level 5

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?

TomKari
Onyx | Level 15

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.

 

 

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 3704 views
  • 1 like
  • 3 in conversation