I just went ahead and made up a data of 20 weeks with four types of diet (averaged for 12 cows into one variable/column). I have attached the dataset here (MadeUpCowsDiet.csv). This type of relationship between Week and Diet column can be described as below. Growth_Diet = (Theta_1 * Week)/(Theta_2 + Week)
where Theta_1 and Theta_2 are the parameters that need to be estimated using regression. The idea is to use PROC NLIN to do non-linear regression and get the Parameters (Theta_1 and Theta_2) for every Diet column and then use the predicted values to plot a regression line (using PROC SGPLOT). The code is as below. PROC IMPORT DATAFILE="~/MadeUpCowsDiet.csv" DBMS=CSV OUT=MadeUpCowsDiet;
RUN;
%MACRO PredictAndPlot(Diet_Col_Name, Theta_1, Theta_2);
%LET PredictedName=Predicted_&Diet_Col_Name;
/* PROC NLIN will do non-linear regression while PROC SGPLOT will utilize the results to fit a curve */
PROC NLIN DATA=MadeUpCowsDiet;
PARAMETERS Theta_1=&Theta_1 Theta_2=&Theta_2;
MODEL &Diet_Col_Name=(Theta_1*Week)/(Theta_2+Week);
OUTPUT Predicted=&PredictedName OUT=Predicted;
RUN;
PROC SGPLOT DATA=Predicted;
SCATTER X=Week Y=&Diet_Col_Name;
SERIES X=Week Y=&PredictedName;
RUN;
%MEND;
/* Now you can call macro for every diet (column). Below is just one example. */
%PredictAndPlot(Gwth_Diet1,8,2); When you run this, then you get the parameter estimates as below from PROC NLIN. Parameters estimate and you get the curve from PROC SGPLOT. Curve Please let me know if this is what you wanted. There is a big possibility that I have underestimated your problem.
... View more