reading a matrix with character values with SAS/IML

reading a matrix with character values with SAS/IML

Post by Philippe Guibl » Tue, 05 Mar 2002 23:18:35



dear sas users,

Does anyone know how to read a sas-dataset containing both numeric and character values within sas iml?

I have used the lines below but sas/iml only reads the numeric variables of the sas-dataset mat1and put it
into mat1.
/*************/
proc iml;

use a.mat1;
read all into mat2;
/*************/
Thanks.

Philippe Guiblin
Office for National Statistics.

For the latest data on the economy and society
consult National Statistics at http://www.statistics.gov.uk

**********************************************************************
Please Note:  Incoming and outgoing email messages
are routinely monitored for compliance with our policy
on the use of electronic communications
**********************************************************************
Legal Disclaimer  :  Any views expressed by
the sender of this message are not necessarily
those of the Office for National Statistics
**********************************************************************

 
 
 

reading a matrix with character values with SAS/IML

Post by Elmaache, Hama » Wed, 06 Mar 2002 00:19:17


Hi Philippe .
run this code to see wnate you wante.
/********************************/

 data data;
input  Name $2. Color $6.   Amount;
cards;
a black    10
a black    15
a red      20
a red      23
a red      27
b black    10
b black    15
b red      23
b red      27
;
run;

proc iml;

use data;
read all var { Amount} into num;
read all var {Name Color} into char;
read all var {Name Color Amount} into char_num;
print num;
print char;
print char_num;
run;
quit;
/********************************/
/********************************/

Barrere

/**********/

-----Original Message-----

Sent: March 4, 2002 9:19 AM

Subject: reading a matrix with character values with SAS/IML

dear sas users,

Does anyone know how to read a sas-dataset containing both numeric and
character values within sas iml?

I have used the lines below but sas/iml only reads the numeric variables of
the sas-dataset mat1and put it
into mat1.
/*************/
proc iml;

use a.mat1;
read all into mat2;
/*************/
Thanks.

Philippe Guiblin
Office for National Statistics.

For the latest data on the economy and society
consult National Statistics at http://www.statistics.gov.uk

**********************************************************************
Please Note:  Incoming and outgoing email messages
are routinely monitored for compliance with our policy
on the use of electronic communications
**********************************************************************
Legal Disclaimer  :  Any views expressed by
the sender of this message are not necessarily
those of the Office for National Statistics
**********************************************************************


 
 
 

reading a matrix with character values with SAS/IML

Post by David L. Casse » Wed, 06 Mar 2002 04:03:27



> Does anyone know how to read a sas-dataset containing both numeric and

character values within sas iml?
Quote:

> I have used the lines below but sas/iml only reads the numeric

variables of the sas-dataset mat1and put it

Quote:> into mat1.
> /*************/
> proc iml;

> use a.mat1;
> read all into mat2;
> /*************/

You don't really want to read numeric and character variables into one
matrix, do you?  IML assumes the matrix is one or the other, not both.
Try something like this instead:

read all var _num_  into mat2;
read all var _char_ into mat3;

HTH,
David
--
David Cassell, CSC

Senior computing specialist
mathematical statistician