BookmarkSubscribeRSS Feed
dishant
Calcite | Level 5

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):(Column).

      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

2 REPLIES 2
jakarman
Barite | Level 11

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 --<-----
Loko
Barite | Level 11

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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1213 views
  • 0 likes
  • 3 in conversation