DATA Step, Macro, Functions and more

How to avoid the conversion Note

Reply
Contributor
Posts: 52

How to avoid the conversion Note

Hi All,

Below is the piece of code,While running this part I am getting below note in my log window.Can you please suggest me the way to avoid it.

Thanks in advance for help.

CODE :

Data dck ;

  char = "&dc." ;

  %do i = 1 %to %sysfunc(countw(&dc.," ")) ;

  var = scan(char,&i.,1);

  r=cats("DC_variable",strip(put(&i.,best.)));

  output;

  %end;

  Run;

LOG:

Data dck ;

char = "name_DC Surname_DC cdm_DC cdc_DC" ;

var = scan(char,1,1);

  r=cats("DC_variable",strip(put(1,best.)));

  output;

  var = scan(char,2,1);

   r=cats("DC_variable",strip(put(2,best.)));

   output;

   var = scan(char,3,1);

   r=cats("DC_variable",strip(put(3,best.)));

  output;

   var = scan(char,4,1);

   r=cats("DC_variable",strip(put(4,best.)));

   output;

   Run;

NOTE: Numeric values have been converted to character values at the places given by:

      (Line)Smiley SadColumn).

      17:30   19:30   21:30   23:30

NOTE: The data set WORK.DCK has 4 observations and 3 variables.

NOTE: DATA statement used (Total process time):

      real time           0.01 seconds

      cpu time            0.00 seconds

Trusted Advisor
Posts: 3,212

Re: How to avoid the conversion Note

The scan function SAS(R) 9.4 Functions and CALL Routines: Reference, Third Edition third parameter is defined as string.

-> Correct the coding

var is defined as length maximum 8 but you are wanting a word/string longer in that 

-> Correct the coding

&1 is a macro string nicely resolved without any blanks.  There is no need voor put and strip cats. In the macro:  r="DC_variable&i"   will do the job.  

-> simplify the coding

---->-- ja karman --<-----
Super Contributor
Posts: 308

Re: How to avoid the conversion Note

Hello,

There is no need to nest the %do loop within the data set.

The following code , I think, is what you are looking for:

%let dc=name_DC Surname_DC cdm_DC cdc_DC;

Data dck ;

  do i = 1 to countw("&dc"," ") ;

  var = scan("&dc",i,"");

  r=cats("DC_variable",strip(put(i,best.)));

  output;

  end;

Run;

Ask a Question
Discussion stats
  • 2 replies
  • 182 views
  • 0 likes
  • 3 in conversation