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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: