BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
_vichz
Fluorite | Level 6

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
PaigeMiller
Diamond | Level 26

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

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

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
_vichz
Fluorite | Level 6

@PaigeMiller thank you for your answer ! I tried and the following message appeared: "unable to allocate sufficient memory" ... 😅

IanWakeling
Barite | Level 11

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.

PaigeMiller
Diamond | Level 26

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
_vichz
Fluorite | Level 6

@PaigeMiller @IanWakeling 

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

 

_vichz_0-1671451017850.png

 

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).

 

PaigeMiller
Diamond | Level 26

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

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/etsug/etsug_expand_details19.htm#etsug_expand...

--
Paige Miller
Rick_SAS
SAS Super FREQ

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;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 7 replies
  • 924 views
  • 7 likes
  • 4 in conversation