05-10-2017 09:30 AM
I need to change data in my numeric columns named NUM1-NUM90 (90 columns).
Whereever its '.' i need to replace it with '0'
Also tthere is a where clause to select model_type.
For example..the query should be: In a dataset for model_type='Business' set all '.' values to '0' for columns(WRA1-WRA90) .
Please help me have a query or suggestion,how to take care of this.Thanks!
05-10-2017 09:35 AM - edited 05-10-2017 09:36 AM
Apply this simple example of 3 columns to your 90 and add a where clause where needed
data have; input WRA1-WRA3; datalines; 1 2 . . 4 6 4 . 9 ; data want(drop = i); set have; array wras[*] WRA1-WRA3; do i = 1 to dim(wras); if wras[i] = . then wras[i] = 0; end; run;
05-10-2017 10:21 AM
You have got your answers from the others, you should attempt a little to make the discussion interesting. Anyway, here you go:
data want(drop = i);
array wras[*] WRA1-WRA90;
if upcase(model_type)='BUSINESS' then do;
do i = 1 to dim(wras);
if wras[i] = . then wras[i] = 0;