Turn on suggestions

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

Showing results for

Options

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 09-16-2021 08:03 AM
(393 views)

data have1;

input bucket$ probability ;

cards;

first 0.0025

second 0.37

third 0.53

fourth 0.89

;

run;

data have2;

input bucket$ z;

cards;

first -2.81

second -0.60

third -0.15

fourth 0.69

;

run;

Hi Everyone,

I have 2 data sets as above. I want to calculate a value(v) as

v = cdf('normal', z+c)

where z = z-value from table have2

c = constant which we will start with 1 and continuously changing it to get the minimum sum of squares difference of V and probability( from table have1).

We are interested in getting the value of C (initially equals 1) such that (V - probability)^2 is minimised.

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

If you have SAS/OR ,could try the following code . or calling @RobPratt

Or if you have SAS/IML ,could try many optimize function like CALL NLPNRA () ,CALL NLPLM() .

@Rick_SAS wrote may blogs about it.

```
data have1;
input bucket$ probability ;
cards;
first 0.0025
second 0.37
third 0.53
fourth 0.89
;
run;
data have2;
input bucket$ z;
cards;
first -2.81
second -0.60
third -0.15
fourth 0.69
;
run;
proc optmodel;
set <str> B;
num p{B} ;
num z{B};
read data have1 into B=[bucket] p=probability;
read data have2 into B=[bucket] z=z;
var c ;
min min=sum{i in B} (cdf('normal', z[i]+c)-p[i])**2;
solve ;
print c.sol;
quit;
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi, Thank you for your quick response. I don't have the mentioned components. Can we use SAS/STAT in this. Or is there any other other way without using SAS/OR and SAS/IML. Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Looks correct to me. I have only two suggestions.

1. Change the second READ DATA statement as follows:

`read data have2 into [bucket] z;`

The index set B has already been populated from the previous READ DATA statement, and z=z is redundant.

2. Use the INIT option to initialize c, as requested by the user:

```
var c init 1;
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi RobPratt,

Can we do this without using SAS/OR and SAS/IML? I don't have the required components as of now.

Can we use SAS/STAT in any way for this?

Can we do this without using SAS/OR and SAS/IML? I don't have the required components as of now.

Can we use SAS/STAT in any way for this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

OK. Here is. The same result with SAS/OR .

```
data have1;
input bucket$ probability ;
cards;
first 0.0025
second 0.37
third 0.53
fourth 0.89
;
run;
proc sort data=have1;by bucket;run;
data have2;
input bucket$ z;
cards;
first -2.81
second -0.60
third -0.15
fourth 0.69
;
run;
proc sort data=have2;by bucket;run;
data want;
merge have1 have2;
by bucket;
run;
proc nlin data=want;
parms c 1;
mean=cdf('normal', z+c);
model probability=mean;
run;
```

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. **

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.