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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 670 views
  • 0 likes
  • 3 in conversation