## proc model : vector of restrictions

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

## Re: proc model : vector of restrictions

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

## Re: proc model : vector of restrictions

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

## Re: proc model : vector of restrictions

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.

## Re: proc model : vector of restrictions

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;``````
Discussion stats
• 3 replies
• 1007 views
• 1 like
• 2 in conversation