I have a parameter 'slope' which depends on 3 parameters (Sets): physician, product and linear_piece
I want to read this data in proc optmodel using 'Read data into...'
My code is something like this:
read data Slope1
into Slope1 = [Physician Product Linear_piece] Slope
Slope[Physician, Product, Linear_piece] = col("Slope");
However this doesn't seem to be working. Is there anything wrong with the code?
The following works fine for me. Maybe you have not declared your index set Slope1 properly. (You will need to change my declarations if some of your data set variables are strings instead of numbers.)
data Slope1;
input Physician Product Linear_piece Slope;
datalines;
1 2 3 4
5 6 7 8
;
proc optmodel;
set <num,num,num> Slope1;
num slope {Slope1};
read data Slope1 into Slope1 = [Physician Product Linear_piece] Slope;
/* Slope[Physician, Product, Linear_piece] = col("Slope");*/
print slope;
quit;
Thanks for the solution - it worked.
One more question. In the same model, after importing data from excel, SAS shows the values of all the parameters stored as 0.
I checked it with this code after the 'Read Data' statements.
print {c in customers,p in products,q in prices: c='1'} likelihood_to_apply
{c in customers,p in products,q in prices: c='1'} expected_profit
;
The value comes as 0. However in the temporary dataset created by SAS, we have the correct values.
I am totally clueless as to why SAS is considering all the numeric values as 0.
Please show us your declarations of these parameters, as well as your READ DATA statements.
Also, did you get any warnings in the log?
Thanks for the reply. No there were no warnings in the log, but I did get notes after the READ DATA statements.
Below is one of the READ DATA statements and the note.
824 read data Slope
825 into [Physician Product Linear_piece]Slope= col("Slope");
NOTE: 1254 non-missing values were discarded due to invalid target indices.
That note is probably because you did not populate the index set for Slope. Compare to the READ DATA in my first reply.
It is hard to tell what's going on without seeing the rest of your code. Please show at least the declarations and READ DATA statements related to likelihood_to_apply and expected_profit.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.