BookmarkSubscribeRSS Feed
srdhoble
Calcite | Level 5

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!

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

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;

 

Shmuel
Garnet | Level 18

data want;

   set have;

        array wr {90} wra1-wra90;

       do i=1 to 90; if wr(i)=. then wr(i)=0; end;

run;

srdhoble
Calcite | Level 5

Where will i have Where clause for Model_type= Business ?

art297
Opal | Level 21
data want;
   set have;
   array wr {90} wra1-wra90;
   id model_type eq 'Business' then do;
      do i=1 to 90;
        if missing(wr(i)) then wr(i)=0;
     end;
  end;
run;

Art, CEO, AnalystFinder.com

 

novinosrin
Tourmaline | Level 20

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);
set have;
array wras[*] WRA1-WRA90;
if upcase(model_type)='BUSINESS' then do;
do i = 1 to dim(wras);
if wras[i] = . then wras[i] = 0;
end;

end;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 900 views
  • 0 likes
  • 5 in conversation