BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Patelbb
Fluorite | Level 6

Hi,

 

I was wondering if anyone could help me with this. I'm new to coding so I apologize if this is a dumb question. I'm getting two notes for the following code:

 

data merged(drop=prefname s_cmtrt s_cmindsp s_cmindc s_cmstdtc s_cmenrf s_cmendtc s_cmany medname);
   merge studyrx(in=studyrx)
         x_cm(in=x_cm);
 by s_siteid s_subjid;
 length end $9;
 label start = "Start(ddMMMyyyy)"
       end = "End(ddMMMyyyy)";
 ** Concatenate prefname and s_cmtrt in parentheses;
    Medication= trim(compress(prefname) || '(' || trim(compress(s_cmtrt)) || ')');
 ** Create new variable for s_cmtrt;
 if (s_cmtrt ne ' ') then medname = Medication;
 else if (s_cmtrt eq ' ') then Medication = 'None';
 ** Create new variable for s_cmindsp where missing equals s_cmindc;
 if (s_cmindsp ne ' ') then Indication = s_cmindsp;
 else if (s_cmindsp eq ' ') then Indication = s_cmindc;
 ** Create new variable that contains numeric values of s_cmstdtc;
 ** If the first character of s_cmstdtc is 'U', leave numeric value missing;
 format start date9.;
 start = input(s_cmstdtc, ??date9.);
    if upcase(substr(start,1,1))= "U" then start = '.';
 
    ** When s_cmenrf is "ONGOING" and s_cmendtc is missing, display the "ONGOING" value;
    if (s_cmenrf eq 'ONGOING' and s_cmendtc eq ' ') then end = 'ONGOING';
 else end = s_cmendtc;
run;
 
Here is the log:
257  data merged(drop=prefname s_cmtrt s_cmindsp s_cmindc s_cmstdtc s_cmenrf s_cmendtc s_cmany medname);
258     merge studyrx(in=studyrx)
259           x_cm(in=x_cm);
260      by s_siteid s_subjid;
261
262      length end $9;
263      label start = "Start(ddMMMyyyy)"
264            end = "End(ddMMMyyyy)";
265
266      ** Concatenate prefname and s_cmtrt in parentheses;
267      Medication= trim(compress(prefname) || '(' || trim(compress(s_cmtrt)) || ')');
268
269      ** Create new variable for s_cmtrt;
270      if (s_cmtrt ne ' ') then medname = Medication;
271      else if (s_cmtrt eq ' ') then Medication = 'None';
272
273      ** Create new variable for s_cmindsp where missing equals s_cmindc;
274      if (s_cmindsp ne ' ') then Indication = s_cmindsp;
275      else if (s_cmindsp eq ' ') then Indication = s_cmindc;
276
277      ** Create new variable that contains numeric values of s_cmstdtc;
278      ** If the first character of s_cmstdtc is 'U', leave numeric value missing;
279
280      format start date9.;
281      start = input(s_cmstdtc, ??date9.);
282      if upcase(substr(start,1,1))= "U" then start = '.';
283
284
285      ** When s_cmenrf is "ONGOING" and s_cmendtc is missing, display the "ONGOING" value;
286      if (s_cmenrf eq 'ONGOING' and s_cmendtc eq ' ') then end = 'ONGOING';
287      else end = s_cmendtc;
288
289  run;
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
      282:22
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      282:52
NOTE: There were 83 observations read from the data set WORK.STUDYRX.
NOTE: There were 300 observations read from the data set WORK.X_CM.
NOTE: The data set WORK.MERGED has 319 observations and 9 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
 
 
Can anyone please help me resolve this? I'm not sure what I'm missing here. Thank you!!
1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

Pay attention that the notes refer to line 282 in the log which is:

281      start = input(s_cmstdtc, ??date9.);
282      if upcase(substr(start,1,1))= "U" then start = '.';

in line 281 you used input function which creates start as numeric variable while

in line 282 you assigned    '.'    which is a character.

 

to get rid of the notes change the assignment to: start = .;

 

View solution in original post

3 REPLIES 3
Shmuel
Garnet | Level 18

Pay attention that the notes refer to line 282 in the log which is:

281      start = input(s_cmstdtc, ??date9.);
282      if upcase(substr(start,1,1))= "U" then start = '.';

in line 281 you used input function which creates start as numeric variable while

in line 282 you assigned    '.'    which is a character.

 

to get rid of the notes change the assignment to: start = .;

 

Reeza
Super User

And you take the substr(start, 1,1) which is a numeric you convert to a number. Use SUBSTRN instead of SUBSTR.

 


@Patelbb wrote:

Hi,

 

I was wondering if anyone could help me with this. I'm new to coding so I apologize if this is a dumb question. I'm getting two notes for the following code:

 

data merged(drop=prefname s_cmtrt s_cmindsp s_cmindc s_cmstdtc s_cmenrf s_cmendtc s_cmany medname);
   merge studyrx(in=studyrx)
         x_cm(in=x_cm);
 by s_siteid s_subjid;
 length end $9;
 label start = "Start(ddMMMyyyy)"
       end = "End(ddMMMyyyy)";
 ** Concatenate prefname and s_cmtrt in parentheses;
    Medication= trim(compress(prefname) || '(' || trim(compress(s_cmtrt)) || ')');
 ** Create new variable for s_cmtrt;
 if (s_cmtrt ne ' ') then medname = Medication;
 else if (s_cmtrt eq ' ') then Medication = 'None';
 ** Create new variable for s_cmindsp where missing equals s_cmindc;
 if (s_cmindsp ne ' ') then Indication = s_cmindsp;
 else if (s_cmindsp eq ' ') then Indication = s_cmindc;
 ** Create new variable that contains numeric values of s_cmstdtc;
 ** If the first character of s_cmstdtc is 'U', leave numeric value missing;
 format start date9.;
 start = input(s_cmstdtc, ??date9.);
    if upcase(substr(start,1,1))= "U" then start = '.';
 
    ** When s_cmenrf is "ONGOING" and s_cmendtc is missing, display the "ONGOING" value;
    if (s_cmenrf eq 'ONGOING' and s_cmendtc eq ' ') then end = 'ONGOING';
 else end = s_cmendtc;
run;
 
Here is the log:
257  data merged(drop=prefname s_cmtrt s_cmindsp s_cmindc s_cmstdtc s_cmenrf s_cmendtc s_cmany medname);
258     merge studyrx(in=studyrx)
259           x_cm(in=x_cm);
260      by s_siteid s_subjid;
261
262      length end $9;
263      label start = "Start(ddMMMyyyy)"
264            end = "End(ddMMMyyyy)";
265
266      ** Concatenate prefname and s_cmtrt in parentheses;
267      Medication= trim(compress(prefname) || '(' || trim(compress(s_cmtrt)) || ')');
268
269      ** Create new variable for s_cmtrt;
270      if (s_cmtrt ne ' ') then medname = Medication;
271      else if (s_cmtrt eq ' ') then Medication = 'None';
272
273      ** Create new variable for s_cmindsp where missing equals s_cmindc;
274      if (s_cmindsp ne ' ') then Indication = s_cmindsp;
275      else if (s_cmindsp eq ' ') then Indication = s_cmindc;
276
277      ** Create new variable that contains numeric values of s_cmstdtc;
278      ** If the first character of s_cmstdtc is 'U', leave numeric value missing;
279
280      format start date9.;
281      start = input(s_cmstdtc, ??date9.);
282      if upcase(substr(start,1,1))= "U" then start = '.';
283
284
285      ** When s_cmenrf is "ONGOING" and s_cmendtc is missing, display the "ONGOING" value;
286      if (s_cmenrf eq 'ONGOING' and s_cmendtc eq ' ') then end = 'ONGOING';
287      else end = s_cmendtc;
288
289  run;
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
      282:22
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      282:52
NOTE: There were 83 observations read from the data set WORK.STUDYRX.
NOTE: There were 300 observations read from the data set WORK.X_CM.
NOTE: The data set WORK.MERGED has 319 observations and 9 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
 
 
Can anyone please help me resolve this? I'm not sure what I'm missing here. Thank you!!

 

Patelbb
Fluorite | Level 6

Thank you so much!! Both solutions helped!!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 840 views
  • 4 likes
  • 3 in conversation