BookmarkSubscribeRSS Feed
Tenno
Calcite | Level 5

Since many vectors are n x 1 upon definition in mathematical notation, while IML vectors are 1 x n upon creation, if I want to use a vector as n x 1, I have to transpose it or “j” it into a vertical rather than horizontal orientation. Is there an IML option that I do not know about that would automatically create vectors as n x 1?

1 REPLY 1
Rick_SAS
SAS Super FREQ

There is no option. In statistics vectors appear in both directions. For example, in a regression context you might encounter Y as a coliumn vector of responses and X[,i] as the i_th explanatory variable.  However, to score the i_th observation requires evaluating a model on X[i,], the i_th row.

I don't understand your comment that "IML vectors are 1 x n upon creation."  Are you thinking of a particular function or operation? In SAS/IML, some functions and operations result in row vectors, such as the LOC and UNIQUE functions and set operations such as SETDIF and XSECT. Also, some functions such as MEAN, VAR, and STD naturally return row vectors.  However, if you read data from a SAS data set or define x=j(10,1), then you get a column vector.

You can use the COLVEC function to ensure that a vector is a column vector. The SHAPE and SHAPECOL functions might also be useful.

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
  • 845 views
  • 0 likes
  • 2 in conversation