BookmarkSubscribeRSS Feed
abhik_giri
Calcite | Level 5

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?

5 REPLIES 5
RobPratt
SAS Super FREQ

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;

abhik_giri
Calcite | Level 5

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.

RobPratt
SAS Super FREQ

Please show us your declarations of these parameters, as well as your READ DATA statements.

Also, did you get any warnings in the log?

abhik_giri
Calcite | Level 5

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.

RobPratt
SAS Super FREQ

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Discussion stats
  • 5 replies
  • 1437 views
  • 3 likes
  • 2 in conversation