BookmarkSubscribeRSS Feed
Patelbb
Fluorite | Level 6

Hi,

 

I was running some code and ended up with the following note. I'm not quite sure how to fix it. Can anybody help please? Thank you!

 

313  **-------------------------------------------------------------------------------**;
314  **  MERGE X_DS AND STUDYRX DATASETS TOGETHER                                        **;
315  **-------------------------------------------------------------------------------**;
316  data merged(drop=complete s_dsdc s_dsterm lcontdt fdosedt);
317     merge studyrx(in=studyrx)
318           x_ds(in=x_ds);
319      by s_subjid;
320
321
322      ** duration on study calculation;
323      duration= lcontdt-fdosedt+1;
324
325      ** study dispostion should create/display as 'STUDY COMPLETED' when complete=YES;
326      if complete= 'YES' then study= "STUDY COMPLETED";
327      else study= trim(compress(s_dsdc) || '(' || trim(compress(s_dsterm)) || ')');
328
329  run;
NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      6 at 323:22
NOTE: There were 83 observations read from the data set WORK.STUDYRX.
NOTE: There were 77 observations read from the data set WORK.X_DS.
NOTE: The data set WORK.MERGED has 83 observations and 7 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
5 REPLIES 5
Astounding
PROC Star

The note refers to this calculation:

 

323      duration= lcontdt-fdosedt+1;

 

It's telling you that for 6 observations, the calculation could not be made because either LCONTDT is missing or FDOSEDT is missing (or both are missing).  Your best recourse is to find out what those values should be, and fix the data.  But if that's not possible, then the calculations just can't be made.

 

Notice that the data sets you are merging contain different numbers of observations:  83 observations in one, but only 77 observations in the other.  On a related note, it's super important that you read the log!  So there are probably some mismatches when you merge, causing one of the variables to be missing.

PeterClemmensen
Tourmaline | Level 20

This happens because either lcontdt or fdosedt contains missing values. An arithmetic operation that contains a missing value will also be missing in SAS.

Reeza
Super User

@Patelbb wrote:

Hi,

 

I was running some code and ended up with the following note. I'm not quite sure how to fix it. Can anybody help please? Thank you!

 

313  **-------------------------------------------------------------------------------**;
314  **  MERGE X_DS AND STUDYRX DATASETS TOGETHER                                        **;
315  **-------------------------------------------------------------------------------**;
316  data merged(drop=complete s_dsdc s_dsterm lcontdt fdosedt);
317     merge studyrx(in=studyrx)
318           x_ds(in=x_ds);
319      by s_subjid;
320
321
322      ** duration on study calculation;
323      duration= lcontdt-fdosedt+1;
324
325      ** study dispostion should create/display as 'STUDY COMPLETED' when complete=YES;
326      if complete= 'YES' then study= "STUDY COMPLETED";
327      else study= trim(compress(s_dsdc) || '(' || trim(compress(s_dsterm)) || ')');
328
329  run;
NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      6 at 323:22


 

Here's a quick lesson in reading these error messages. Note the colour coding that lines up the instructions on how to find the issue. 

First identify the line, which it gives you explicitly as 323. 

Then the issue is at 22 characters in, I added 1234567890 underneath, each 0, is a 10, so second 0 is 20, and 22 is 2 in red. That indicates the issue is at fdosedt. 

 

323      duration= lcontdt-fdosedt+1;

12345678901234567890123

 

When you do math on missing values it returns missing, which is why this note/warning shows up. You can get rid of it in several ways, one is change it to a function (SUM() vs +) which will treat missing as 0, or do the calculation conditionallly, add an IF statement to control the calculation so it only happens when fdosedt is not missing.

 

 

 

 

FreelanceReinh
Jade | Level 19

@Reeza wrote:

 

Then the issue is at 22 characters in, I added 1234567890 underneath, each 0, is a 10, so second 0 is 20, and 22 is 2 in red. That indicates the issue is at fdosedt. 

 

323      duration= lcontdt-fdosedt+1;

12345678901234567890123

 


Hi @Reeza,

 

I agree that it's helpful to study these notes in the log, but I think the column number (22) points to the minus sign in this case, i.e., to where the first "operation on missing values" in this line occurred. It doesn't reveal whether lcontdt or fdosedt contains the missing value if not both are missing. (At least I can't see a difference in my PC SAS 9.4 log.)

Reeza
Super User

@FreelanceReinh wrote:

@Reeza wrote:

 

Then the issue is at 22 characters in, I added 1234567890 underneath, each 0, is a 10, so second 0 is 20, and 22 is 2 in red. That indicates the issue is at fdosedt. 

 

323      duration= lcontdt-fdosedt+1;

12345678901234567890123

 


Hi @Reeza,

 

I agree that it's helpful to study these notes in the log, but I think the column number (22) points to the minus sign in this case, i.e., to where the first "operation on missing values" in this line occurred. It doesn't reveal whether lcontdt or fdosedt contains the missing value if not both are missing. (At least I can't see a difference in my PC SAS 9.4 log.)


You are correct, the column indicator is not exactly correct so OP should check all variables involved in the calculation. 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

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
  • 5 replies
  • 5947 views
  • 3 likes
  • 5 in conversation