Hello,
I am trying to code all variables in my dataset so that any observations less than 0 are coded as missing.
I tried something like this, but I guess the "_ALL_" trick only works in certain situations and doesn't work here?
if _ALL_ < 0 then _ALL_=.;
Does anyone know of an easier way to get SAS to perform this data step all at once, without me having to list each variable on their own on a separate line?
Thank you!!!
I assume you have all numeric variables, as <0 doesn't apply to character variables. So ... the data step method you need is called an ARRAY.
data want;
set have;
array x _numeric_;
do i=1 to dim(x);
if x(i)<0 then call missing(x(i));
end;
run;
I assume you have all numeric variables, as <0 doesn't apply to character variables. So ... the data step method you need is called an ARRAY.
data want;
set have;
array x _numeric_;
do i=1 to dim(x);
if x(i)<0 then call missing(x(i));
end;
run;
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!
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.