SAS Optimization, and SAS Simulation Studio

turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-24-2012 11:20 PM

Hi guys,

Need your help. i am trying to maximize two variables' (dep and org*s) correlaton by changing the var (0<s<0.8). The below program (1st) works fine when i put [org*s] in the correlation formula. However, if i create a new variable, ads = org*s, the program doesn't work anymore. The reason i need to create a new variable ads is that there will be more calculations involved and i don't want to write an extreme long function in max procesure. i need to break out the long function to several pieces. i remember the old Proc NLP can do it.

This may be a very naiive question but do need your help. thx. Here are the two programs. Again, the 2nd doesn't work and i don't know how to fix it.

Thanks again!

Fisher

data cor;

input org dep;

cards;

11785895 7.42

2335492 7.58

2345245 7.58

2392912 7.53

12755890 7.63

2918402 7.67

2773183 7.68

2824198 7.65

12263433 7.53

;

run;

* program 1 that works;

proc optmodel;

set w;

number org{w};

number ads{w};

number dep{w};

var s{w} >= 0 <= .8 init 1;

read data cor into w = [_n_] org dep;

max correlation = (10*sum{i in w}((org**s )*dep) - (sum{i in w}((org*s))) * (sum{i in w}(dep)))*

/ (sqrt(10*sum{i in w}((org**s )^2) - (sum{i in w}((org*s)))^2) * sqrt(10*sum{i in w}(dep^2) - (sum{i in w}(dep))^2));*

solve;

print s correlation;

quit;

* program 2 that doesn't work;

proc optmodel;

set w;

number org{w};

number ads{w};

number dep{w};

var s{w} >= 0 <= .8 init 1;

read data cor into w = [_n_] org dep;

for {i in w} ads * = org * s;*

max correlation = (10*sum{i in w}(ads**dep ) - (sum{i in w}(ads)) * (sum{i in w}(dep)))*

/ (sqrt(10*sum{i in w}(ads^2) - (sum{i in w}(ads))^2) * sqrt(10*sum{i in w}(dep^2) - (sum{i in w}(dep))^2));

solve;

print s correlation;

quit;

Accepted Solutions

Solution

03-26-2012
01:01 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-26-2012 01:01 PM

In program 2, you have declared ads as a numeric parameter, so the resulting objective is constant. Instead, you should declare ads as an implicit variable (and omit the FOR loop) as follows:

impvar ads {i in w} = org * * s ;*

All Replies

Solution

03-26-2012
01:01 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-26-2012 01:01 PM

In program 2, you have declared ads as a numeric parameter, so the resulting objective is constant. Instead, you should declare ads as an implicit variable (and omit the FOR loop) as follows:

impvar ads {i in w} = org * * s ;*

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-26-2012 01:34 PM

Thanks a lot RobPratt. It really helps. i may need to bother you again when i have more questions (high chance)

Fisher