BookmarkSubscribeRSS Feed
ryankey
Calcite | Level 5

HI, I got a matrix. Each column has its own name. How to get the names of the columns and save them into a vector?

for example, how to get the column names in the following matrix?

proc iml;
n = {1 2 3, 4 5 6};      /* 2 x 3 numeric */
c = {'a' 'b', 'c' 'd'};  /* 2 x 2 character */

nNames = "n1":"n3";
cNames = "c1":"c2";
create ndat from n[colname=nNames];
append from n;
create cdat from c[colname=cNames];
append from c;

quit;

Many thanks!

Sincerely,

Ryan

1 REPLY 1
ryankey
Calcite | Level 5

Got it. Use CONTENTS function.

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
  • 1307 views
  • 0 likes
  • 1 in conversation