BookmarkSubscribeRSS Feed
BY2
Obsidian | Level 7 BY2
Obsidian | Level 7

Hi, 

 

Sample data:

IDcolAcolBcolCcolDcolE1colE2colE3colE4colE5colE6colE7colE8colE9ColWColRCol_ipcol_i99col_ILcol_hcol_srcol_ccol_ML
1230.0065440.50183075844450.566207-0.013960.245639-0.094550.78098500000.0005950.2065-2.481373.0902321748895    
4560.002650.2316542826525740.42042-0.259340.4236680.759272000000.0005460.2251-2.788213.090232435886.1    
7890.0065440.50182007689580.1749450.2042220.2179820.021944-0.034730.2123290.0414250.91196700.0003880.2065-2.481373.0902321141552    
11220.0128510.5018292006286040.42042-0.259340.4236680.759272000000.0003880.1831-2.230693.0902321585257    
14550.0355060.45853579560.5541160.3413460.185772-0.130750.1444230.7099120000.0001650.1403-1.80543.090232931034.2    
17880.002650.45689849580.1749450.2042220.2179820.021944-0.034730.2123290.0414250.91196700.0001330.2251-2.788213.090232206655.2    
21210.0293630.45661432440.42042-0.259340.4236680.759272000000.0001280.1476-1.890243.090232664473.7    
24540.0293630.45593691960.5541160.3413460.185772-0.130750.1444230.7099120000.0001150.1476-1.890243.090232596421.8    
27870.0293630.5018526164150.566207-0.013960.245639-0.094550.78098500000.0001020.1476-1.890243.090232589429.3    
31200.0128510.45366476350.566207-0.013960.245639-0.094550.78098500007.09E-050.1831-2.230693.090232259662.9    
34530.0128510.45218674440.42042-0.259340.4236680.759272000004.23E-050.1831-2.230693.090232154939.5    
37860.050130.4598330.5280.1749450.2042220.2179820.021944-0.034730.2123290.0414250.91196701.9E-060.1298-1.643593.09023212604.4    
41190.0019410.459.27E+0830.5898530.1735270.7886460000000.0179290.2289-2.887593.09023222651290    
41190.0013360.451768465630.5898530.1735270.7886460000000.0003420.2322-3.003153.090232334349.2    

 

Would like to perform Excel Solver in SAS that solves col_h, col_sr, col_c and col_ML. These 4 variables equation are interrelated as shown below:

 

1. col_sr = sqrt(col_R/Y)

2. col_c = colB*colW*cdf('normal',((Col_ip+Col_R*Col_99)/sqrt(1-Col_R**2)))

3. col_ML = colB*colC*cdf('normal',((Col_ip+col_h*col_sr*Col_99)/sqrt(1-(col_h*col_sr)**2)))

4. col_h = sumproduct of (colE1-colE9, b1-b9)

where b1-b9:

cy1 = sumproduct(col_c*colE1);

.

. (repeat till cy9)

.

.cy9 = sumproduct(col_c*colE9);

lm = sumproduct(cy1-cy9, cy1-cy9);

b1 = cy1/lm

.

. (repeat till b9)

.

b9 = cy9/lm

 

To solve Y, the difference of sum(col_ML) and sum(col_IL) is value of 0. 

**Note: SAS IML and Proc OptModel procedure is not found in my SAS License. 

 

Any help would be greatly appreciated. Thank you!

 

6 REPLIES 6
TomKari
Onyx | Level 15

This is quite a chunk of work! To begin, can you verify that this code is producing what you expect, setting Y and col_h to 1:

 

data Have;
	input ID colA colB colC colD colE1 colE2 colE3 colE4 colE5 colE6 colE7 colE8 colE9 ColW ColR Col_ip col_i99 col_IL col_h col_sr col_c col_ML;
	cards;
123 0.006544 0.5018 30758444 5 0.566207 -0.01396 0.245639 -0.09455 0.780985 0 0 0 0 0.000595 0.2065 -2.48137 3.090232 1748895 . . . . 
456 0.00265 0.231654 28265257 4 0.42042 -0.25934 0.423668 0.759272 0 0 0 0 0 0.000546 0.2251 -2.78821 3.090232 435886.1 . . . . 
789 0.006544 0.5018 20076895 8 0.174945 0.204222 0.217982 0.021944 -0.03473 0.212329 0.041425 0.911967 0 0.000388 0.2065 -2.48137 3.090232 1141552 . . . . 
1122 0.012851 0.501829 20062860 4 0.42042 -0.25934 0.423668 0.759272 0 0 0 0 0 0.000388 0.1831 -2.23069 3.090232 1585257 . . . . 
1455 0.035506 0.45 8535795 6 0.554116 0.341346 0.185772 -0.13075 0.144423 0.709912 0 0 0 0.000165 0.1403 -1.8054 3.090232 931034.2 . . . . 
1788 0.00265 0.45 6898495 8 0.174945 0.204222 0.217982 0.021944 -0.03473 0.212329 0.041425 0.911967 0 0.000133 0.2251 -2.78821 3.090232 206655.2 . . . . 
2121 0.029363 0.45 6614324 4 0.42042 -0.25934 0.423668 0.759272 0 0 0 0 0 0.000128 0.1476 -1.89024 3.090232 664473.7 . . . . 
2454 0.029363 0.45 5936919 6 0.554116 0.341346 0.185772 -0.13075 0.144423 0.709912 0 0 0 0.000115 0.1476 -1.89024 3.090232 596421.8 . . . . 
2787 0.029363 0.5018 5261641 5 0.566207 -0.01396 0.245639 -0.09455 0.780985 0 0 0 0 0.000102 0.1476 -1.89024 3.090232 589429.3 . . . . 
3120 0.012851 0.45 3664763 5 0.566207 -0.01396 0.245639 -0.09455 0.780985 0 0 0 0 7.09E-05 0.1831 -2.23069 3.090232 259662.9 . . . . 
3453 0.012851 0.45 2186744 4 0.42042 -0.25934 0.423668 0.759272 0 0 0 0 0 4.23E-05 0.1831 -2.23069 3.090232 154939.5 . . . . 
3786 0.05013 0.45 98330.52 8 0.174945 0.204222 0.217982 0.021944 -0.03473 0.212329 0.041425 0.911967 0 1.90E-06 0.1298 -1.64359 3.090232 12604.4 . . . . 
4119 0.001941 0.45 9.27E+08 3 0.589853 0.173527 0.788646 0 0 0 0 0 0 0.017929 0.2289 -2.88759 3.090232 22651290 . . . . 
4119 0.001336 0.45 17684656 3 0.589853 0.173527 0.788646 0 0 0 0 0 0 0.000342 0.2322 -3.00315 3.090232 334349.2 . . . . 
run;

data Inter01;
	set Have;
	Y = 1;
	col_h = 1;
	col_sr = sqrt(ColR / Y);
	col_c = colB * colW * cdf('normal', (Col_ip + (ColR * col_i99)) / sqrt(1 - (ColR**2)));
	col_ML = colB * colC * cdf('normal', (Col_ip + (col_h * col_sr * col_i99)) / sqrt(1 - ((col_h * col_sr)**2)));
run;
BY2
Obsidian | Level 7 BY2
Obsidian | Level 7

Yes, Once Y is solved from getting sum of col_ML = sum of col_IL. The rest of the variables will be computed. The four equations are all interdependent on each other, and the tricky part is that the equation of col_h is quite complex. 

 

Appreciate your help, Thanks. 

TomKari
Onyx | Level 15

Okay, I'm working on Step 4 now. I'm not familiar with SUMPRODUCT, but I've given something a try. Can you verify that I'm calculating cy1 to cy9 correctly?

 

cy1 cy2 cy3 cy4 cy5 cy6 cy7 cy8 cy9
616469143.51 159027663.37 787563937.92 38326186.54 32143193.48 16022889.35 1121528.87 24690339.68 0.00
BY2
Obsidian | Level 7 BY2
Obsidian | Level 7

Hi, cy1 to cy9 should be some smaller values instead of 6 digits number. Please take note of the difference of colC and col_c, hope you didnt use the wrong variable. Apologies for the confusion, let me explain sumproduct by using one of the example below:

 

1. In this example, In order to obtain cy1, will need to sum up every row of (col_c * colE1). Please refer below:

row1: col_c * colE1

row2: col_c * colE1

...

...

(do the same till the last row and then sum all of them up will be the sumproduct of col_c * colE1).

 

2. However, it is a little different for the equation of lm where it is the sumproduct of cy1-cy9. Please refer below:

row1: cy1*cy1 + cy2*cy2 + cy3*cy3 + .... + cy9*cy9

Note: lm should be same across all observation. 

 

Thank you. 

TomKari
Onyx | Level 15

Yes, you are correct, I did exactly that! Thanks for the catch.

 

How does this look for cy1 to cy9?

 

cy1 cy2 cy3 cy4 cy5 cy6 cy7 cy8 cy9
8.20E-05 1.83E-05 9.46E-05 9.59E-06 1.22E-05 8.53E-06 2.83E-07 6.24E-06 0.00E+00
BY2
Obsidian | Level 7 BY2
Obsidian | Level 7

Yes, that is correct. Please proceed. 

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!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1095 views
  • 0 likes
  • 2 in conversation