BookmarkSubscribeRSS Feed
Gick
Pyrite | Level 9
/*Here my proposition of code*/

%macro remplacer_points(table_in, table_out);

data &table_out;
set &table_in;


array old_vars(*) _numeric_;
array new_vars(*) $ _temporary_;

do i = 1 to dim(old_vars);
/* Have Names variable */
var_name = vname(old_vars[i]);

/* Remplace (.) by (_) */
new_vars[i] = tranwrd(var_name, '.', '_');
end;


do i = 1 to dim(old_vars);
if not missing(new_vars[i]) then
rename old_vars[i]=new_vars[i];
end;

drop i var_name;
run;
%mend;


%remplacer_points(table_in=BDD_recod, table_out=BBB);
Gick
Pyrite | Level 9
/*Another code*/
%macro remplacer_points(table_in, table_out);

proc sql noprint;
select name into :varlist separated by ' '
from dictionary.columns
where libname = upcase(libname) and memname = upcase("&table_in");
quit;


data &table_out;
set &table_in;


%let num_vars = %sysfunc(countw(&varlist));
%do i = 1 %to &num_vars;
/* Obtenir le nom de la variable */
%let var_name = %scan(&varlist, &i);
%put &var_name.;


%let new_var_name = %sysfunc(tranwrd(&var_name, '.', '_'));
%put &new_var_name.;


rename &var_name = &new_var_name;
%end;
run;
%mend; Always the same

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
  • 16 replies
  • 5141 views
  • 1 like
  • 8 in conversation