Statistical programming, matrix languages, and more

Alternative to proc iml?

Reply
New Contributor
Posts: 3

Alternative to proc iml?

Hello everyone,

I have just started with SAS and am already stuck; I really hope that someone can help me out *please*

I have been provided a macro to create a new variable within my dataset, but it contains "proc iml" which, apparently,

my SAS Software does not have (can not use?...)

So my question is, is there an alternative proc or anything that I can use so I can still use the macro?

Thanks in advance!

Esteemed Advisor
Esteemed Advisor
Posts: 7,232

Re: Alternative to proc iml?

Best to post your code and example of what data you have and what you would like it to look like.

New Contributor
Posts: 3

Re: Alternative to proc iml?

I'll try :-)

The part of the macro that uses proc iml and where it stops is:

proc iml;

    call symput('anzahl_eintraege',left(char(nrow({&liste}))));

quit;

%let anzahl_eintraege= %eval(&anzahl_eintraege*1);

proc iml;

    a = t(1:&anzahl_eintraege);

    b = {&liste};

    c = length(b);

    create listfile var{a b c};

    append;

    close listfile;

quit;

I have a dataset with a variable "ops_ko" for which I have 100 columns, "ops_ko1", "ops_ko2" and so on to "ops_ko100".

If any single one of these columns within a row contains a certain value, I want a (newly added) dummy variable to say 1, else 0.

The macro is supposed to do that, except that my SAS does not seem to work with proc iml so it is not beeing executed :-(

Does that make it better...?

Respected Advisor
Posts: 3,775

Re: Alternative to proc iml?

Show that with example, this is what I have and this is what I need, data.  The have/need scenario.

New Contributor
Posts: 3

Re: Alternative to proc iml?

That is an example of my data (as I posted before, there is a total of 100 ops_ko-columns)

What I need is to add another variable that has the value 1 if in any of the ops_ko in a row has a certain value. For example if that value was 0107 then the newly added variable would be 1 for the first, second and fifth data row, if it was 9260 it would only be 1 for the second.

typ_altertyp_gebaufn_anlaufn_grdops_ko1ops_ko2ops_ko3ops_ko4ops_ko5ops_ko6ops_ko7
182N01079603080103
192G010792608800c0
102E010112750
142E010157583
172N010732221632
211N050187161
Esteemed Advisor
Esteemed Advisor
Posts: 7,232

Re: Alternative to proc iml?

Well, if its simply checking each column for a value and assigning a result then try (it generates a dataset with 100 if statements - I have assumed your value is 99):

data _null_;

  call execute('data want;

                  set have;

                  attrib result format=best.;

                  result=0');

  do i=1 to 100;

    call execute('if ops_ko'||put(i,1.)||'=99 then result=1;');

  end;

  call execute('run;');

run;

SAS Super FREQ
Posts: 3,415

Re: Alternative to proc iml?

I assume that &liste is a comma separated list that looks like this

     x1,abc2,pdq,x4

The first PROC IML simply creates a macro variable with the number of entries in the list. For my example, &anzahl_eintraege will have the value 4.

I don't think that the %LET statement does anything useful.

The second PROC IML statement creates a data set named LISTFILE that contains three variables, A, B, and C.

A is just a counter. B is the name of the variables. C is the number of characters in the variable name. For my example, you'd get

A     B      C

1     x1     2

2     abc2 4

3     pdq   3

4     x1     2

You can replace this with a DATA step. I'll let someone else give you that code.

SAS Super FREQ
Posts: 3,415

Re: Alternative to proc iml?

Short answer is "no, there isn't an easy replacement." Usually people incorporate SAS/IML because they want to perform matrix computations that are not readily available in Base SAS or SAS/STAT.

However, as @RW9 says, a definitive answer is not possible without knowing what the SAS/IML code in the macro does.

Your Bio doesn't give your affiliation, but I'll mention that SAS/IML will becaome available to  all academic students and faculty in May 2014. See this announcement: SAS/IML available to all students through SAS Analytics U - The DO Loop

Ask a Question
Discussion stats
  • 7 replies
  • 644 views
  • 0 likes
  • 4 in conversation