Hello to whomever can help
I have a data set like following:
I tried the following program, but it give me error.
PROC IML;
print (mu_vec['MSFT']);
error message is like following. Please help. Thank you.
If you are using a column name attribute, you need to specify the name as a column:
mu_vec[, 'MSFT'];
For more information and examples, see "Access rows or columns of a matrix by names."
First you have to read the data from the data set into a matrix or vector.
Read the article "Reading ALL variables INTO a matrix."
Is the data in a data set that has one observation and three variables? If so, then the PROC IML statements look like this:
proc iml;
use Have;
read all var {"MSFT" "NORD" "SBUX"} into mu_vec;
close Have;
If you want to read all of the numeric variables, you can use this:
read all var _NUM_ into mu_vec[colname=varNames];
If you are using a column name attribute, you need to specify the name as a column:
mu_vec[, 'MSFT'];
For more information and examples, see "Access rows or columns of a matrix by names."
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.