BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Reeza
Super User
DOSUBL instead of CALL EXECUTE which runs immediately.
acordes
Rhodochrosite | Level 12

I’ll try tomorrow and let you know

acordes
Rhodochrosite | Level 12

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;
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
  • 17 replies
  • 6178 views
  • 6 likes
  • 5 in conversation