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
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
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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.