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