Hello,
I have a very large dataset with multiple variables. Some of these variables have a value of zero, which I'd like to convert to 'NULL'. How would I go about doing this?
Eg:
Desciprtion, VariableA#, VariableB#.......VariableZ#
Thanks!
In SAS, missing numerical values are represented by a dot. So do
if variable = 0 then variable = .;
One way assuming all the variables are numeric:
data want; set have; array v var1 var2 varx; /* add variables as needed*/ do i=1 to dim(v); if v[i]=0 then v[i]=.; end; drop i; run;
If the variables are numeric then try this:
PROC FORMAT;
value Null .="NULL";
run;
data want;
set Have ;
array Change _numeric_;
do over change;
if change>10 then change=.;
end;
FORMAT _NUMERIC_ Null.;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.