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

Hello.

 

I want to read a dataset with two columns into proc iml, but it only prints one column when I print it.

 

Can someone tell me what I am doing wrong please?

proc iml;
        use data.lossdata;
	read all var {lob loss} into A[colname = varNames];
	print A;
quit;
1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

You can read the variables into vectors:

read all var {lob loss};

 

For more information about reading numeric and character variables, see

How to read data set variables into SAS/IML vectors

Reading ALL variables INTO a matrix

View solution in original post

6 REPLIES 6
Ksharp
Super User

These two variables have the same type ? both are numeric or character ?

SchalkBurger
Fluorite | Level 6

The lob is a character and loss numeric.

IanWakeling
Barite | Level 11

@Ksharp has diagnosed the problem correctly, as matrices are either all character or all numeric.  Whenever you run code, it is always good to check the SAS log for messages, as I suspect you have missed a warning message about a type missmatch.

 

Also check the recent thread on this forum called "Matrix with strings in IML", in particular the link that Rick gives to the Table structure.

Rick_SAS
SAS Super FREQ

You can read the variables into vectors:

read all var {lob loss};

 

For more information about reading numeric and character variables, see

How to read data set variables into SAS/IML vectors

Reading ALL variables INTO a matrix

SchalkBurger
Fluorite | Level 6

Thank you all. 
I appreciate the help.

There is still a lot to learn.

Rick_SAS
SAS Super FREQ

Yes, there is always more to learn, but to get started you might try some of the tips at "Ten tips for learning the SAS/IML language", especially the SAS Global Forum paper  "Getting Started with the SAS/IML Language" (Wicklin 2013)

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
  • 6 replies
  • 5666 views
  • 5 likes
  • 4 in conversation