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**.
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 12-18-2022 09:57 AM
(373 views)

Hi everyone,

I have a column vector (1 2 3 ... 20 000). I would like to know how to create a 20 000 x 20 000 matrix which columns correspond to the first column vector I mentioned.

Thank you 🙂

1 ACCEPTED SOLUTION

Accepted Solutions

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

I think you can use the IML REPEAT statement.

If you have named the column vector you already have to be X, then you want

`want_matrix = repeat(x,1,20000);`

--

Paige Miller

Paige Miller

7 REPLIES 7

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

I think you can use the IML REPEAT statement.

If you have named the column vector you already have to be X, then you want

`want_matrix = repeat(x,1,20000);`

--

Paige Miller

Paige Miller

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

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

You will need about 3GB to store a 20000x20000 matrix and this is probably more than your default memory allocation for SAS. To see run:

```
proc options option=memsize value;
run;
```

There is a command line option -MEMSIZE that you use when starting the SAS application to increase the allocation. Alternatively, describe why you need to create such a large matrix, and what you want to do with it, then perhaps someone can suggest a way of doing it that needs less memory.

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

I am in complete agreement with @IanWakeling .

@_vichz Please explain to us why you need such a huge repetitive matrix. What are you going to do with it?

--

Paige Miller

Paige Miller

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

First of all, thank you for taking the time to answer my question 🙂

I have to compute the moving average of a financial time series in order to detrend it. Here, G is the density of a gaussian (mean=0, standard deviation=10). I thought I could do that using matrices. Initially, I took the whole time series (approximately 20 000 observations). Now I sampled it and took the "interesting" part (500 observations).

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

If you have a license to SAS/ETS, moving averages can be computed by PROC EXPAND.

--

Paige Miller

Paige Miller

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

It is unlikely that the value at time t=20000 times series is related to the value at t=1. Typically, correlations are observed for small time values such as 1-7 (daily), 30 (monthly), or maybe 365 (annually). It might be that you are sampling too frequently (eg, microseconds) and you should decrease the sampling rate.

Most time series procedures in SAS create the lagged effects internally, so there is rarely a need to create a matrix whose columns are the lagged effects. However, to answer your question, you can use the LAG function in SAS IML to create a matrix that contains the lagged effects:

```
proc iml;
v = T( 1:10 ); /* input vector */
Lags = lag(v, 0:5); /* matrix of lags 0,1,2,... */
print Lags;
```

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

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.