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!
Best to post your code and example of what data you have and what you would like it to look like.
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...?
Show that with example, this is what I have and this is what I need, data. The have/need scenario.
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_alter | typ_geb | aufn_anl | aufn_grd | ops_ko1 | ops_ko2 | ops_ko3 | ops_ko4 | ops_ko5 | ops_ko6 | ops_ko7 |
18 | 2 | N | 0107 | 96030 | 80103 | |||||
19 | 2 | G | 0107 | 9260 | 8800c0 | |||||
10 | 2 | E | 0101 | 12750 | ||||||
14 | 2 | E | 0101 | 57583 | ||||||
17 | 2 | N | 0107 | 3222 | 1632 | |||||
21 | 1 | N | 0501 | 87161 |
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;
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.
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
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!
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.