BookmarkSubscribeRSS Feed
vchfurereyt
Calcite | Level 5

I have a data file that looks like this:fev.PNG

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.

3 REPLIES 3
art297
Opal | Level 21

The coalesce function will do what you want. e.g.:

data want;
  set have;
  actualreads=coalesce(actualreads,estimatedreads);
run;

Art, CEO, AnalystFinder.com

 

PeterClemmensen
Tourmaline | Level 20
data have1;
   set have;
   ActualReads=ifn(missing(ActualReads)=1, EstimatedReads, ActualReads);
run
Astounding
PROC Star

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.

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 5529 views
  • 4 likes
  • 4 in conversation