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 .
@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.
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;
want=shape(have,0,4,blankstr(nleng(have)));
This could "works in all cases" .
@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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.