sas - Multiple proc reg from a macro variable -


i trying shorten program. want make multiple regressions 1 one list of independant variables , single dependant variable.

this list of variables:

%let dept1 = bpt1; %let indept1 = age poimest1 taimest1 tugt1 tlev5xt1 march2t1 marrapt1 tamaxt1 tamint1; 

this i'm doing right now:

model &dept1= age /stb; model &dept1= poimest1 /stb; model &dept1= taimest1 /stb; model &dept1= tugt1 /stb; model &dept1= tlev5xt1 /stb; model &dept1= march2t1 /stb; model &dept1= marrapt1 /stb; model &dept1= tamaxt1 /stb; model &dept1= tamint1 /stb; 

i'm trying find way write similar proc gplot syntax is:

plot &dept1*(&indept1); 

is there way of doing so? :)

you can perform loop on &indept1. consider properties of &indept1:

  • it's string of words
  • it's space-delimited
  • it ends after point

let's think of &indept1 sentence. it's nonsensical sentence, every sentence has number of words before ends. can count how many words in sentence until hit sort of end mark, , can know position each word counting until hit end indicator. consider following example:

1   2     3     4   5     6    7   8    9  v end quick brown fox jumps on lazy dog. 

there 9 words in sentence. know end of sentence because period marks end of sentences in english language. each word associated number, , represents unique index specific sentence. example, if selected word 4 sentence above, word fox.

a sentence has @ least 1 word in it, , sas knows &indept1 ends using hidden internal end-of-sentence indicator. can count how many words in sentence starting first word , ending @ end-of-sentence indicator. let's exploit these 2 concepts select every word one-by-one &indept1:

%macro model(data=, x=, y=);     %let total_words = %sysfunc(countw(&x) );      %do = 1 %to &total_words;         %let selected_var = %scan(&x, &i);          proc reg data=&data;              model &y = &selected_var / stb;         run;     %end; %mend; 

once compiled, can input number of variables want argument macro, provided follows sentence rules discussed above.

%model(data=have       , x=age poimest1 taimest1 tugt1 tlev5xt1 march2t1 marrapt1 tamaxt1 tamint1       , y=bpt1); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -