BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Yegen
Pyrite | Level 9

I know the following code works well, but does anyone have alternative suggestions to write a more efficient code that replaces zeros with missing values? 


Here is a sample dataset: 

data work.sample;
 infile cards expandtabs truncover;
input 	ID	shrout	shrout1	shrout2;
cards;
26232409	0	2	50997000
26232409	0	3	50997000
26232409	53598	0	50997000
10623630	10097	2	0
5856168			.		.	.
;
run;

Here is the code:

data work.sample;
	modify work.sample;
	array vars{*} shrout shrout1 shrout2; 
	do i = 1 to dim(vars);
        if vars{i}=0 then call missing(vars{i});
	end;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

This was actually asked yesterday on here, see latest posts. You only need the last part, PROC STDIZE 

 

https://communities.sas.com/t5/Base-SAS-Programming/Back-fill-empty-rows-with-zero-values/m-p/363458...

View solution in original post

2 REPLIES 2
Reeza
Super User

This was actually asked yesterday on here, see latest posts. You only need the last part, PROC STDIZE 

 

https://communities.sas.com/t5/Base-SAS-Programming/Back-fill-empty-rows-with-zero-values/m-p/363458...

Yegen
Pyrite | Level 9

Perfect, thanks for pointing that out, @Reeza

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 3020 views
  • 1 like
  • 2 in conversation