I have a data file that looks like this:
There are many cases where a value for the column "ActualRead" will not exist, and therefore it will be an estimated read that shows up in the "EstimatedReads" column. My question is how do I combine these two columns so that I have a single column that contains the actual reads, and replaces the missing actual reads with the estimated reads in the other column?
P.s. I am a SaS novice. I can handle some programming, but would prefer a solution in EG. Thanks.
The coalesce function will do what you want. e.g.:
data want; set have; actualreads=coalesce(actualreads,estimatedreads); run;
Art, CEO, AnalystFinder.com
data have1;
set have;
ActualReads=ifn(missing(ActualReads)=1, EstimatedReads, ActualReads);
run
Since you call yourself a novice, I thought you might want the simplest version:
data want;
set have;
if ActualReads=. then ActualReads=EstimatedReads;
drop EstimatedReads;
run;
Dropping EstimatedReads might not be a great idea, but I wasn't sure if that was part of the question or not.
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 save with the early bird rate—just $795!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.