BookmarkSubscribeRSS Feed
Yooyork
Calcite | Level 5
Hi All,

I am learning proc optmodel and writing the follow code. why the second one is ok but the first one is not. please advise. thank you.

proc optmodel;

var p1 >=0 <=1;
number n=4;
number k{1..n} =[0 1 2 3];
put k
  • =;



    min j=sum{i in 1..n} p1**k*(1-p1)**(800-k);

    con j>=1-0.95;
    solve;
    create data solution from p1=p1;
    run;
    quit;

    proc optmodel;

    var p1 >=0 <=1;


    min j=(1-p1)**800 + p1**1*(1-p1)**799+p1**2*(1-p1)**798+p1**3*(1-p1)**797;

    con j>=1-0.95;
    solve;
    create data solution from p1=p1;
    run;
    quit;
  • 2 REPLIES 2
    Yooyork
    Calcite | Level 5
    why i can not post correct code? could anyone tell me?
    Philipp_SAS
    SAS Employee
    Hello,

    Unfortunately the forum does not like some character combinations that are needed for OPTMODEL code.

    The problem seems to be with "less than or equal", if you write it in symbols it disappears and also text following it. You might try posting your code again replacing "less than or equal" with something like LE or so. And check the preview if something else causes problem.

    Sorry for the inconvenience.

    SAS Innovate 2025: Call for Content

    Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

    Submit your idea!

    Multiple Linear Regression in SAS

    Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

    Find more tutorials on the SAS Users YouTube channel.

    Discussion stats
    • 2 replies
    • 1057 views
    • 0 likes
    • 2 in conversation