Programming the statistical procedures from SAS

Proc NLIN : parameter array confusion when initial values are given in dataset

Accepted Solution Solved
Reply
Respected Advisor
Posts: 4,749
Accepted Solution

Proc NLIN : parameter array confusion when initial values are given in dataset

In the simplified NLIN example below, giving initial values to model parameters in the PARAMETER statement is NOT equivalent to specifying them in a dataset. It looks like parameter names are not known at the time of array definitions when the parameters are given in a dataset. Is this an undocumented "feature"? 

 

/* Parameter array given initial values in PARAMETER statement. Works fine. */
proc nlin data=sashelp.class;
parameters w=1 h=1;
bounds w h >= 0;
array x{*} weight height;
array y{*} w h;
s = 0;
do i = 1 to dim(x);
s = s + x{i}*y{i};
end;
model age = s;
run;

 

/* Same problem. Parameter array given initial values in PDATA dataset. Doesn't work. */
data pd;
Parameter="w"; Estimate=1; output;
Parameter="h"; Estimate=1; output;
run;

proc nlin data=sashelp.class;
parameters / pdata=pd;
bounds w h >= 0;
array x{*} weight height;
array y{*} w h;
s = 0;
do i = 1 to dim(x);
s = s + x{i}*y{i};
end;
model age = s;
run;

 

ERROR: The variable y was referenced but not given a value.

 

PG

Accepted Solutions
Solution
‎09-25-2015 06:23 AM
SAS Super FREQ
Posts: 3,547

Re: Proc NLIN : parameter array confusion when initial values are given in dataset

I am pleased to report that your code runs without error in SAS/STAT 14.1 (released in July 2015 with SAS 9.4m3). Consequently, it looks like someone agreed with you that this "feature" was not ideal.

By the way, try the new SAS color-coded editor in the new COmmunity. Click the "running man" icon when you paste in the code. It will appear color coded.

View solution in original post


All Replies
Solution
‎09-25-2015 06:23 AM
SAS Super FREQ
Posts: 3,547

Re: Proc NLIN : parameter array confusion when initial values are given in dataset

I am pleased to report that your code runs without error in SAS/STAT 14.1 (released in July 2015 with SAS 9.4m3). Consequently, it looks like someone agreed with you that this "feature" was not ideal.

By the way, try the new SAS color-coded editor in the new COmmunity. Click the "running man" icon when you paste in the code. It will appear color coded.
Respected Advisor
Posts: 4,749

Re: Proc NLIN : parameter array confusion when initial values are given in dataset

Thank you Rick!
PG
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 230 views
  • 2 likes
  • 2 in conversation