سؤال

I have a dataset that I'm trying to create tables from but I need to filter out the observations that don't belong in those tables. I'm still learning my way around SAS, so I don't know how to drop the observations using conditions.

Basically I want to drop the observations that have an ID value that is not four digits (in terms of length). Is this possible?

Thanks in advance.

هل كانت مفيدة؟

المحلول

Assuming your ID is character, and you don't consider blanks digits:

if lengthn(id) ~= 4 then delete;

If your ID is numeric:

if 1000 <= id <= 9999 then output;

نصائح أخرى

If id is character:

where length(id) = 4;

If id is numeric:

where id between 1000 and 9999;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top