0

我正在学习 SAS 中的 drop_conditions。我要求提供三个变量的样本,但只检索到两个观察值。请指教!谢谢!

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;

输出

4

1 回答 1

1

您的条件/比较未正确指定,我认为您正在寻找IN操作员在一行中进行多重比较。我很惊讶您的日志中没有错误。

而不是以下内容:

if (LotArea = 7000:9000)

尝试:

if (lotArea in (7000:9000))

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

应该

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

编辑:您还需要为 drop_condition 变量指定长度,而不是格式以确保变量足够长以容纳指定的文本。之后根据指定条件使用 proc freq 验证您的答案也很有用,例如:

proc freq data=temp;
where drop_condition=:'01';
tables drop_condition*lot_area;
run;
于 2016-01-01T02:25:48.827 回答