sas - Logistic regression Macro -


    %macro intercept(i1= ,i2= );       %let n = %sysfunc(countw(&i1));         %do = 1 %to &n;           %let val_i1 = %scan(&i1,&i,'');           %let val_i2 = %scan(&i2,&i,'');           data scores;             set repeat_score2;             /* segment 1 probablity score  */             p1 = 0;             z1 =   &val_i1      +                             *      0.03            +                     r         *    -0.0047841        +                     p         *   -0.000916081      ;              p1 = 1/(1+2.71828**-z1);              /* segment 2 probablity score  */            p2 = 0;            z2 =   &val_i2           +                    r           *       0.09           +                    m           *     0.012786245      +                    c           *    -0.00179618        +            p2 = 1/(1+2.71828**-z2);             logit_score = 0;            if max(p1,p2) =      p1 logit_score = 1;            else if max(p1,p2) = p2 logit_score = 2;          run;           proc freq data = scores;             table logit_score * clu_ /nocol norow nopercent;          run;     %end;   %mend; %intercept (i1=-0.456491042, i2=-3.207379842, i3=-1.380627318 , i4=0.035684096, i5=-0.855283373); %intercept (i1=-0.456491042 0, i2=-3.207379842 -3.207379842, i3=-1.380627318 -1.380627318, i4=0.035684096 0.035684096,             i5=-0.855283373 -0.855283373); 

i have above macro takes intercept 2 of above models , calculates probablity score , assigns a value to segment based on probablity score.

the first problem above macro when execute macro 1 argument each it's resolving macro variable 'n' 2 , executing twice. first iteration, it's giving right results while second it's wrong.

for second implementation(macro 2 aruguments each) n resolving 3 , scan resolving both of values @ time (eg. i1 iteration -0.45 , 0), if remove space, taking '.' delimiter , resolving ( 0,45,0 - 1 each iteration). don't results case.

how work right way?

thanks!!!

%scan , countw function default consider punctuation symbols , blanks delimiters. since arguments include decimal points, need state explicitly delimiter should blank both countw , %scan. have done %scan, not countw. 2nd line of code should be:

 %let n = %sysfunc(countw(&i1,' ')) 

and i'm not sure if it's typo or formatting thing, in %scan functions third argument looks 2 quotes '', not quote-blank-quote ' ' should be.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -