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 2024

    Innovate_SAS_Blue.png

    Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

    If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

    Register now!

    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
    • 738 views
    • 0 likes
    • 2 in conversation