mercredi 10 juillet 2019

Simple If and or statement

Hello i am trying to write what i thought would be a simple if and or statement in sas but i am running into trouble. The first condition after the and statement -in this case- "Nbr = 1000" does not process and is skipped over.

data want;
set have;
if family = "Pink flag" and NBR = 1000 OR NBR = 1500 OR NBR 2500 
   then place = PF;
 /* this logic is repeated with different family names, nbrs and places */

this is the output i get

family    NBR       Place
Pink Flag 1000      NJ
Pink Flag 1000      NJ
Pink Flag 1000      NJ
Pink Flag 1025      NJ
Pink Flag 1025      NJ
Pink Flag 1025      NJ
Pink Flag 1500      PF
Pink Flag 1500      PF
Pink Flag 1500      PF

as you can see it works for the 1500 but not the 1000

what i want

family    NBR       Place
Pink Flag 1000      PF
Pink Flag 1000      PF
Pink Flag 1000      PF
Pink Flag 1025      NJ
Pink Flag 1025      NJ
Pink Flag 1025      NJ
Pink Flag 1500      PF
Pink Flag 1500      PF
Pink Flag 1500      PF

i have also tried to use a where statement.

Thanks!

Aucun commentaire:

Enregistrer un commentaire