Hi All,
I am confused about how to arrange my data to run a probit model. I am aware the model needs to be run in another package other than IML (namely QLIM), but I thought it would be easiest to arrange the data using IML.
I have data on 484 farms over 132 months for four variables. Currently, I have each variable in its own matrix as follows:
Here is the Quantity Matrix:
Month_1 Month_2 .... Month_j
Farm_1 Q_1_1 Q_1_2 Q_1_j
Farm_2 Q_2_1 Q_2_2 Q_2_j
. .
.
.
Farm_i Q_i_1 Q_i_2 Q_i_j
I have matrices of equal dimensions for prices, variable costs, and total costs. Column j represents the j'th month and row i represents the i'th farm in each matrix.
If anyone can give me some guidance about how to arrange this data, I would greatly appreciate it. Thanks!!
Use the COLVEC function to create a single vector from each matrix. Then save the data to a SAS data set, along with indicator variables for the MONTH and FARM variables. This is called transforming the data from "wide to long" form. You might like to read the article "Plotting multiple time series in SAS/IML."
You can use the ROW and COL functions to easily create the indicator variables, as follows:
proc iml;
/* 4 months (columns) and 3 farms (rows) */
Q = {1 2 3 4,
5 6 7 8,
9 10 11 12};
Qvec = colvec(Q);
Farm = colvec(row(Q));
Month = colvec(col(Q));
print Farm Month QVec;
Use the COLVEC function to create a single vector from each matrix. Then save the data to a SAS data set, along with indicator variables for the MONTH and FARM variables. This is called transforming the data from "wide to long" form. You might like to read the article "Plotting multiple time series in SAS/IML."
You can use the ROW and COL functions to easily create the indicator variables, as follows:
proc iml;
/* 4 months (columns) and 3 farms (rows) */
Q = {1 2 3 4,
5 6 7 8,
9 10 11 12};
Qvec = colvec(Q);
Farm = colvec(row(Q));
Month = colvec(col(Q));
print Farm Month QVec;
Wow, thanks Rick. You are a wonderful help every time. I appreciate your expertise!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.