I’ll try tomorrow and let you know
Brilliant, So the final code that works look like:
I have to fix what @Quentin cautioned, tranwrd does not care about word bounderies, probably I'll go for regex.
data cars;
set sashelp.cars;
id=put(_n_, 4.);
keep id _numeric_;
run;
proc sql;
select name||"=var" || strip(put(monotonic(), 3.)) into :reny separated by ' '
from dictionary.columns where libname='WORK' and memname='CARS'
and name ne "id";
quit;
data unknown;
set cars;
rename &reny.;
run;
data unknown;
set unknown;
array numy(10) var1-var10;
var_rand=rand('integer', 1, 10);
if rand('uniform', 0, 1) le 0.05 then do;
numy(var_rand)= numy(var_rand)*0.9;
end;
drop var_rand;
run;
proc contents data=cars out=namy_ok;
run;
proc contents data=unknown out=nok;
run;
data together;
merge cars unknown;
by id;
run;
data matched;
format _from _to $32. r2 8.3;
output;
run;
data matched;
set matched(obs=0);
run;
proc sql;
select name into :vary separated by ' '
from nok where type=1;
quit;
%put &vary.;
data _null_;
set WORK.NAMY_OK(obs=10 where=(type=1 and ^index(lowcase(name), 'var') ));
rc=dosubl ('
ods output ModelInfo=model SelectionSummary=selsum;
proc glmselect data=together ;
model ' || name || ' = &vary. / selection=stepwise( stop=1 ) noint;
run;
proc sql;
select tranwrd("&vary.", strip(EffectEntered),"") into :vary
from WORK.SELSUM;
quit;
%put &vary.;
proc sql;
insert into matched(_from, _to, r2 )
select ' || quote(name) || ', strip(EffectEntered), RSquare
from WORK.SELSUM;
quit;');
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.