I have a matrix (let's call it D) with 20 rows (+ column name) and 2 columns. The matrix has been sorted in a particular way, and I want to read the first of every 4 values in the the first column to another matrix. The following code worked on a small "test" dataset (small enough that I could check the results manually), but is there a reason it could produce wrong results (for example, read a number twice from a particular set of four, but zero times from another set)?
In other words, does anyone see anything wrong with this code? Is there a better way of doing what I have done here?
Use this. It uses the DO function to generate the sequewnce {1, 5, 9,...}:
t_row = do(1, nrow(D), 4);
T = D[t_row, 1];
Have you considered using the var _n_ along with a divisibility function I believe it is called MODZ () ??
Use this. It uses the DO function to generate the sequewnce {1, 5, 9,...}:
t_row = do(1, nrow(D), 4);
T = D[t_row, 1];
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.
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.