Search code examples
parameterssasproc

I cannot export parameter estimates for different groups using proc model in SAS


I have been working on a distribution model. I divided my dataset into to two parts to make 2-fold validation. What I want is perform a proc model and get the estimated parameters into another dataset in SAS. I can do that easily by adding outparms= option to the procedure and it works. But when I add by group; option, It only shows the parameters for the last group (in my case group 2). I have an exaple sas code and corresponding output as follows:

data work.have;
    input group y1 x1 x2;
    datalines;
    1 10 0.5 25
    1 12 0.7 30
    1 9 0.6 28
    2 8 0.4 35
    2 11 0.5 40
    2 10 0.45 37
;
run;

proc sort data=work.have;
    by group;
run;

proc model data=work.have noprint outparms=work.parm;
    by group;
    parms c1=1 c2=1 c3=1;
    y1 = exp(c1 + c2*x1 + c3/x2); 
    fit y1;
run;
quit;

Here is what I get by running the code above. I want parameters estimates for both groups in a same dataset. this is what I get

Any ideas? Thanks in advance.


Solution

  • That looks like a BUG. Report it to SAS https://support.sas.com/en/technical-support.html

    In the mean time run multiple PROC MODEL steps with different WHERE statements and combine the results.

    proc model data=work.have noprint outparms=work.parm1;
        where group=1;
        by group;
        parms c1=1 c2=1 c3=1;
        y1 = exp(c1 + c2*x1 + c3/x2); 
        fit y1;
    run;
    quit;
    
    proc model data=work.have noprint outparms=work.parm2;
        where group=2;
        by group;
        parms c1=1 c2=1 c3=1;
        y1 = exp(c1 + c2*x1 + c3/x2); 
        fit y1;
    run;
    quit;
    
    data parm;
     set parm1-parm2;
    run;