BookmarkSubscribeRSS Feed
Sternchen
Calcite | Level 5

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!

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

Sternchen
Calcite | Level 5

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...?

data_null__
Jade | Level 19

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

Sternchen
Calcite | Level 5

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
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

Rick_SAS
SAS Super FREQ

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.

Rick_SAS
SAS Super FREQ

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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 7 replies
  • 2677 views
  • 0 likes
  • 4 in conversation