Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 05-05-2016 10:21 AM
(922 views)

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!!

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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;
```

2 REPLIES 2

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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;
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Wow, thanks Rick. You are a wonderful help every time. I appreciate your expertise!

**Don't miss out on SAS Innovate - Register now for the FREE Livestream!**

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

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.