BookmarkSubscribeRSS Feed
animesh123
Obsidian | Level 7
If Cp1=psg and psg-seg= land and cp2 ="" then rank=2 else rank=1
2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

This is Data Step Syntax. The Data Step does not have a Case Statement. Instead, I think you want to write a Select Statement and do something like

 

select;
   when (Cp1 = psg and psg-seg = land and cp2 = "") rank = 2;
   otherwise rank = 1;
end;
PaigeMiller
Diamond | Level 26

@animesh123 wrote:
If Cp1=psg and psg-seg= land and cp2 ="" then rank=2 else rank=1

Replace IF with CASE WHEN, clean up the syntax after THEN

 

case when Cp1=psg and psg-seg= land and cp2 ="" then 2 else 1 end as rank

As pointed out by @PeterClemmensen you can't use this in a DATA step, only in PROC SQL

--
Paige Miller

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1605 views
  • 1 like
  • 3 in conversation