0

I am learning drop_conditions in SAS. I am requesting a sample on three variables, however only two observations are retrieved. Please advise! Thank you!

data temp;
set mydata.ames_housing_data;
format drop condition $30.;
if (LotArea in (7000:9000)) then drop_condition = '01: Between 7000-9000 sqft';
else if (LotShape EQ 'IR3') then drop_condition = '02: Irregular Shape of Property';
else if (condition1 in 'Artery' OR 'Feedr') then drop_condition = '03: Proximity to arterial/feeder ST';

run;

proc freq data=temp;
tables drop_condition;
title 'Sample Waterfall';
run; quit;

OUTPUT

Starbucks
  • 1,448
  • 3
  • 21
  • 49

1 Answers1

1

Your conditions/comparisons aren't specified correctly, I think you're looking for the IN operator to do multiple comparisons in a single line. I'm surprised there aren't errors in your log.

Rather than the following:

if (LotArea = 7000:9000)

Try:

if (lotArea in (7000:9000))

and

if (condition1 EQ 'Atrery' OR 'Feedr')

should be

if (condition1 in ('Atrery', 'Feedr'))

EDIT: You also need to specify a length for the drop_condition variable, instead of a format to ensure the variable is long enough to hold the text specified. It's also useful to verify your answer afterwards with a proc freq against the specified conditions, for example:

proc freq data=temp;
where drop_condition=:'01';
tables drop_condition*lot_area;
run;
Reeza
  • 20,510
  • 4
  • 21
  • 38