BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
panda
Quartz | Level 8

Hi all - 

 

I want to create a matrix with 24 rows and 120 columns, the ideal dataset looks like this:

A0 A1 A2 A3   ....A59 B0 B1 B2 B3 ... B59

0   0   0     0         0      0   0   0   0        0

RIght now cannot figure out how to name the columns, my code is attached here (this code does not work):

proc iml;
c = j(24, 120, 0);
varNames = "A0" : "A59"; 
varNames = "B0" : "B59";
create data from c [colname = varNames];
append from c;
close data;

Create A columns and B columns and merge them together might help but eventually I want to create a matrix from A to Z, which has 1440 columns, so that approach might not be good enough. 

Any idea? Thanks!!

 

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenKuhfeld
Rhodochrosite | Level 12

Just concatenate your name vectors:

 

proc iml;
c = j(24, 120, 0);
varNames = ("A0" : "A59") || ("B0" : "B59");
create data from c [colname = varNames];
append from c;
close data;
quit;

proc contents varnum; ods select position; run;

View solution in original post

1 REPLY 1
WarrenKuhfeld
Rhodochrosite | Level 12

Just concatenate your name vectors:

 

proc iml;
c = j(24, 120, 0);
varNames = ("A0" : "A59") || ("B0" : "B59");
create data from c [colname = varNames];
append from c;
close data;
quit;

proc contents varnum; ods select position; run;

sas-innovate-2024.png

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.

 

Register now!

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
  • 1 reply
  • 1204 views
  • 2 likes
  • 2 in conversation