Replace missing values ​​in SAS

How to replace all missing values ​​with zeros in SAS? I have a text file that I dump in SAS to process some geodata, but whenever it has no value, it interrupts operations. Is there a way to change this without specifying each field? I have over 200.

How do i do this:

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 this for each field?

+6
source share
2 answers

You can set all missing values ​​to 0 as follows:

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

This converts any numeric value to "." to 0

+16
source

Another option:

 proc stdize data=mydata reponly missing=0 out=newdata; var _numeric_; run; 

If you have SAS / STAT, probably faster than the datastep option for large datasets.

+7
source

Source: https://habr.com/ru/post/946330/


All Articles