Turn on suggestions

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

Showing results for

- Home
- /
- Analytics
- /
- Forecasting
- /
- proc model : vector of restrictions

Options

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

☑ This topic is **solved**.
Need further help from the community? Please
sign in and ask a **new** question.

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

Posted 08-25-2022 07:52 AM
(1006 views)

Hi All,

I run a non-linear regression using proc model. Proc model as you know have two options of restrictions on parameters: bound and restrict.

I have almost same restriction that returns 100 times, for example :

x1*x2*a+x3*b*t = k(t), when t=0.25,0.5,0.75,....,25 and k is fixed(number) for each t. i.e each t has different k

x1, x2, x3 - parameters

It looks like :

x1*x2*a+x3*b*0.25 = 60

x1*x2*a+x3*b*0.5 = 75

x1*x2*a+x3*b*0.75 = 79

...

Is there any way to write these restrictions in proc model in one restrict? Maybe put t and k into a dataset, that i could take the values from there?

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions

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

Alexey,

If you want to programmatically generate your list of restrictions then you can use the SAS macro language. Here's an example that shows how a RESTRICT statement could be generated from values stored in a data set.

Marc

```
data d;
do t = 2 to 12 by 2;
output;
end;
run;
data _null_;
length eqs $ 1024;
set d;
eqname = 'eq'||left(put(_n_,6.));
call symput(eqname, "lhs = " || t);
run;
%macro restricts;
restrict
%do i = 1 %to 6;
%unquote(&eq&i)
%if &i ne 6 %then,
%end;
;
%mend restricts;
proc tmodel;
```

... your model code ...
%restricts;
quit;

3 REPLIES 3

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

Yes. You can specify multiple restrictions by separating them with commas on the RESTRICT statement:

```
restrict x1*x2*a+x3*b*0.25 = 60,
x1*x2*a+x3*b*0.5 = 75,
x1*x2*a+x3*b*0.75 = 79;
```

Also, you may be interested in using PROC TMODEL to estimate your model. PROC TMODEL uses the same syntax as PROC MODEL, but it has an improved non-linear optimization engine that is well suited to problems with nonlinear restrictions.

Marc

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

Of course, i can write these restrictions, but it not looks nice to write 100 restrictions, therefore i asked a question if there are any other way to write these restriction in more "normal" way.

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

Alexey,

If you want to programmatically generate your list of restrictions then you can use the SAS macro language. Here's an example that shows how a RESTRICT statement could be generated from values stored in a data set.

Marc

```
data d;
do t = 2 to 12 by 2;
output;
end;
run;
data _null_;
length eqs $ 1024;
set d;
eqname = 'eq'||left(put(_n_,6.));
call symput(eqname, "lhs = " || t);
run;
%macro restricts;
restrict
%do i = 1 %to 6;
%unquote(&eq&i)
%if &i ne 6 %then,
%end;
;
%mend restricts;
proc tmodel;
```

... your model code ...
%restricts;
quit;

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.