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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.