I have a script that loops through tables in a given library. Once the table is grabbed there is a sub loop where it loops through column name and suppose to update them removing the "/" slashes. All is good but does not read the columns properly when it reach such a column the issue is in the line below where ¤tvar = table name dynamically picked. &next_value. = column name original for example "ABC/D" &yt = new column name that is "ABCD" set LIBREF.¤tvar. (rename= (&next_value. = &yt.)); but it does not work! It will work if you manually typed set LIBREF.XYZ (rename= ('ABC/D'n = 'ABCD')); All the best and much appreciated any help Script below: /* Step I */ LIBNAME libref 'F:\FOLDERWITHTABLES'; RUN; /* Step II */ %let target_lib = 'LIBREF'; proc sql noprint; select memname into :varlist separated by ' ' from dictionary.tables where libname=&target_lib. and memtype="DATA" and memname="TABLENAMEPICKED"; %let n=&sqlobs; quit; %MACRO abc; /* First loop picking table names */ %do i=1 %to &n; %let currentvar = %scan(&varlist,&i); /* Second sub loop picking column names */ proc contents data=LIBREF.¤tvar. out=contents noprint; run; proc sql; select name into :varlist2 separated by ' ' from contents; %let n2=&sqlobs; quit; %local i2 next_value x; %let i2=1; %do %while (%qscan(&varlist2, &i2, ' ') ne ); %let next_value = %qscan(&varlist2, &i2, ' '); data _null_; /*%let x = call symputx('x', translate(&next_value,'','/'));*/ %put &next_value || ' - ' || &i2; /*call symputx('yt', translate(&next_value.,'_','/'));*/ %let yt = %sysfunc(translate(&next_value.,'_','/')); %let counter = %sysfunc(findw(&next_value.,'/')); %put &next_value || ' - ' || &i2 || ' - ' || &yt || ' - ' || &counter; /* conversion */ data LIBREF.¤tvar.; set LIBREF.¤tvar. (rename= (&next_value. = &yt.)); run; run; %let i2 = %eval(&i2 + 1); %end; %end; %MEND abc; %abc;
... View more