BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ksharp
Super User

Here is a question for @Rick_SAS .

Why I have to use 

want=shape(have,0,4,blankstr(nleng(have)));

to make it work.

 

I can't use

want=shape(have,0,4,blankstr(4));

or

want=shape(have,0,4,' ');

or event

want=shape(have,0,4);

I think IML should enhance itself to make its language more convenience to use .

NKormanik
Barite | Level 11

@Ksharp , the error I received above came from:

want=shape(Text_Lines,0,4);

I tried the procedure you provided with other text files, however, and all went perfectly.  Thus, it seems there was something about that one large text file that caused the problem.  Perhaps no approach works in all cases, hmmm.

 

 

Ksharp
Super User

I found you need specify both ncol and nrow to make it work.

data have;
input have $ ;
cards;
a
b
c
d
e
f
g
h
i
j
;

proc iml;
use have;
read all var {have};
close;

want=shape(have,3,4);

print want;

create want from want;
append from want;
close;
quit;

 

If you want use 0 to let IML guess nrow, then you need specify the third argument(Padding value which MUST have the same length of HAVE matrix ) , that is really weird I think it is (LOG didn't imply this problem).

data have;
input have $ ;
cards;
a
b
c
d
e
f
g
h
i
j
;

proc iml;
use have;
read all var {have};
close;

want=shape(have,0,4,'        ');  /*here padding 8 blanks which is the same length as string HAVE*/

print want;

create want from want;
append from want;
close;
quit;

 

Ksharp
Super User
want=shape(have,0,4,blankstr(nleng(have)));

This could "works in all cases" .

NKormanik
Barite | Level 11

@Ksharp , greatly appreciate your attention.  You're a saint.

 

As said, your initial solution works perfectly.  But if it stops working for some reason I'll try one of your additional ideas.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 19 replies
  • 4059 views
  • 21 likes
  • 8 in conversation