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;
This was actually asked yesterday on here, see latest posts. You only need the last part, PROC STDIZE
This was actually asked yesterday on here, see latest posts. You only need the last part, PROC STDIZE
Perfect, thanks for pointing that out, @Reeza.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.