替换SAS中的缺失值 [英] Replace missing values in SAS

查看:203
本文介绍了替换SAS中的缺失值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在SAS中将所有缺失的值替换为零?我有一个文本文件,可以将其转储到SAS中以处理一些地理数据,但是每当缺少一个值时,它都会中断操作.有没有一种方法可以在不指定每个字段的情况下进行更改?我有200多.

How do you replace all missing values with zeroes in SAS? I have a text file that I dump into SAS to process some geo data, but whenever it has a missing value it breaks the operations. Is there a way to change this without specifying each field? I have over 200.

我这样做的方式是:

data geo_cali_north;
set geo_cali_north;
if polar_data eq . then 0;
if lat_xvar eq . then 0;
run;

如何避免在每个字段中都这样做?

How can I avoid doing this for every field?

推荐答案

您可以使用以下方法将所有缺失值设置为0:

You can set all the missing values to 0 with like this:

data myData;
set myData;
array a(*) _numeric_;
do i=1 to dim(a);
if a(i) = . then a(i) = 0;
end;
drop i;

这将转换任何数字."到0

This will convert any numeric "." to a 0

这篇关于替换SAS中的缺失值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆