BookmarkSubscribeRSS Feed
Patelbb
Fluorite | Level 6

Hi,

 

I was wondering if anyone can help with my code. I'm new to coding so I apologize if this is a dump question. I keep getting the following notes in my code and I'm not sure how to fix it.

 

Here is the log:

 

250  data merged(drop=prefname s_cmtrt s_cmindsp s_cmindc s_cmstdtc s_cmenrf s_cmendtc s_cmany medname scrfail);
251     merge studyrx(in=studyrx
252                   where= (SCRFAIL ne 'YES'))
253           x_cm(in=x_cm);
254      by s_siteid s_subjid;
255
256      length end $9;
257      label start = "Start(ddMMMyyyy)"
258            end = "End(ddMMMyyyy)";
259
260      ** Concatenate prefname and s_cmtrt in parentheses;
261      Medication= trim(compress(prefname) || '(' || trim(compress(s_cmtrt)) || ')');
262
263      ** Create new variable for s_cmtrt;
264      if (s_cmtrt ne ' ') then medname = Medication;
265      else if (s_cmtrt eq ' ') then Medication = 'None';
266
267      ** Create new variable for s_cmindsp where missing equals s_cmindc;
268      if (s_cmindsp ne ' ') then Indication = s_cmindsp;
269      else if (s_cmindsp eq ' ') then Indication = s_cmindc;
270
271      ** Create new variable that contains numeric values of s_cmstdtc;
272      ** If the first character of s_cmstdtc is 'U', leave numeric value missing;
273
274      format sort date9.;
275      sort = input(s_cmstdtc, ??date9.);
276      if upcase(substrn(sort,1,1))= "U" then sort = .;
277
278      if substr(start,1,1)eq 'U' then start = 'Unknown';
279
280
281      ** When s_cmenrf is "ONGOING" and s_cmendtc is missing, display the "ONGOING" value;
282      if (s_cmenrf eq 'ONGOING' and s_cmendtc eq ' ') then end = 'ONGOING';
283      else end = s_cmendtc;
284
285  run;
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
      278:15
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      278:45
NOTE: There were 77 observations read from the data set WORK.STUDYRX.
      WHERE SCRFAIL not = 'YES';
NOTE: There were 300 observations read from the data set WORK.X_CM.
NOTE: The data set WORK.MERGED has 313 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.09 seconds
      cpu time            0.04 seconds
 
Thank you!
3 REPLIES 3
PaigeMiller
Diamond | Level 26

Is the variable START numeric? Because the way your code is written, it must be character; if it really is numeric then that would explain the NOTEs in the LOG.

--
Paige Miller
Reeza
Super User

How is this different than your question yesterday? It's literally the exact same notes. 

 

https://communities.sas.com/t5/SAS-Programming/Coding-Help/m-p/518938

Tom
Super User Tom
Super User

You need be more careful in what variables you are referencing.

Take this little block of code:

271      ** Create new variable that contains numeric values of s_cmstdtc;
272      ** If the first character of s_cmstdtc is 'U', leave numeric value missing;
273
274      format sort date9.;
275      sort = input(s_cmstdtc, ??date9.);
276      if upcase(substrn(sort,1,1))= "U" then sort = .;

You convert the characters in S_CMSTDTC into a date value in SORT.  But then try to use a character function on the numeric variable SORT.  Didn't you mean to check S_CMSTDTC?  Also shouldn't you check it BEFORE trying to convert it to a date? 

 

But even easier just delete the last line since the assignment statement above it will have already converted strings that are not valid dates (including strings that start with the letter U) to missing values.

 

Also look at this block of code earlier

263      ** Create new variable for s_cmtrt;
264      if (s_cmtrt ne ' ') then medname = Medication;
265      else if (s_cmtrt eq ' ') then Medication = 'None';

The comment mentions only one input variable, but the IF statement is reading from some other variable named MEDICATION.  Then the ELSE statement will modify that MEDICATION variable, but do nothing with the MEDNAME variable.  Did you mean to change the MEDICATION variable?  Did you mean to not set the MEDNAME variable to anything?  Is it a new variable or an existing variable that is being read in from the source dataset?

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1291 views
  • 0 likes
  • 4 in conversation