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

Hello to whomever can help

 

I have a data set like following:

Capture.PNG

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.

Capture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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."

View solution in original post

3 REPLIES 3
Rick_SAS
SAS Super FREQ

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];
BingL
Obsidian | Level 7
Hello Rick

Thank you for your response and help.

Data was create in PROC IML procedure.

It is like following code:

names = {'MSFT' 'NORD' 'SBUX'};
mattrib mu_vec c=names;

actually I haven't tried the following.

mu_vec[, 'MSFT'];
Rick_SAS
SAS Super FREQ

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."

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!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2321 views
  • 2 likes
  • 2 in conversation