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.

    hackathon24-white-horiz.png

    The 2025 SAS Hackathon has begun!

    It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

    Latest Updates

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