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.

    Ready to join fellow brilliant minds for the SAS Hackathon?

    Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

    Register today!
    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
    • 994 views
    • 0 likes
    • 2 in conversation