Simple data pull, not merging tables or anything. Can I replace null values in PROC SQL statement like I can in the following DATA satement:
DATA TABLE1;
SET TABLE2;
IF OBS1 = . THEN OBS1 = 0;
RUN;
I've looked at the IFN function but cannot get it to work or find any example to reference.
If statements dont function in proc sql but you can do either of the following.
Case
when obs1 = . then 0
else obs1
end as obs1
or you can simply do this
sum(obs1, 0) as obs1
Why SQL and not a data step?
IMHO the most elegant solution is the coalesce() coalescec() functions.
I am actually trying to perform an AVG function in a simple SQL statement:
PROC SQL;
SELECT OBS1,
OBS2,
AVG(OBS3) AS AVGOBS
FROM TABLE1;
QUIT;
I'm trying to graph results but null values throws the results off.
If just to replace the missing value, A simple SUM should do:
PROC SQL; SELECT OBS1, OBS2, SUM(OBS3,0) AS OBS3 FROM TABLE1; QUIT;
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.