简体   繁体   English

根据长度删除SAS中的观察值

[英]Dropping observations in SAS based on length

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. 我仍在学习有关SAS的方法,所以我不知道如何使用条件删除观察值。

Basically I want to drop the observations that have an ID value that is not four digits (in terms of length). 基本上,我想删除ID值不是四位数(就长度而言)的观察值。 Is this possible? 这可能吗?

Thanks in advance. 提前致谢。

Assuming your ID is character, and you don't consider blanks digits: 假设您的ID是字符,并且您不考虑空白数字:

if lengthn(id) ~= 4 then delete;

If your ID is numeric: 如果您的ID是数字:

if 1000 <= id <= 9999 then output;

If id is character: 如果id是字符:

where length(id) = 4;

If id is numeric: 如果id为数字:

where id between 1000 and 9999;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM