Questions tagged [sas-iml]

SAS/IML is the matrix programming language component to SAS (similar to R).

SAS/IML is the matrix language component of SAS software. It interfaces with the base SAS programming environment, allowing you to smoothly transition from matrix operations to dataset operations, and to use SAS' full suite of statistical tools while enjoying the power of a fully featured matrix language.

SAS/IML also allows an interface into R, to allow users to take advantage of the power of SAS while maintaining the flexibility of using R packages as well.

For more information see http://www.sas.com/technologies/analytics/statistics/iml/index.html

98 questions
0
votes
3 answers

Holding Sampled Macro Variable Constant

Hopefully a simple answer. I'm doing a simulation study, where I need to sample a random number of individuals, N, from a uniform distribution, U(25,200), at each of a thousand or so replications. Code for one replication is shown below: %LET U =…
Ryan W.
  • 21
  • 4
0
votes
1 answer

SAS IML Use symget on left side

In SAS/IML is it possible to change a variable if only a macro with its name is available? Using symget on left side produces mistake: proc iml; variable = 0; call symput ('macVar', 'variable'); /* &macVar = 1;*/ symget('macVar') = 1; …
0
votes
1 answer

SAS IML pass reference to variable defined in macro

In SAS/IML I try to pass to a user defined module a reference to a variable that is defined in macro. The module changes the variable value. Since call of the function is in the do-loop I cannot use &-sign. However use of symget does not work. Here…
0
votes
1 answer

SAS IML use of Mattrib with Macro (symget) in a loop

In an IML proc I have several martices and several vectors with the names of columns: proc IML; mydata1 = {1 2 3, 2 3 4}; mydata2 = {1 2, 2 3}; names1 = {'red' 'green' 'blue'}; names2 = {'black' 'white'}; To assign column names to…
0
votes
2 answers

converting 3 variable into a matrix form to create a heatmap in SAS

I'm trying to convert 3 vairables into a matrix, for expample if you have the following: (CHAR) (char) (num) Var1 Var2 Var3 A B 1 C D 2 E F 3 A D 4 A F 5 C B 6 C F …
Heman
  • 3
  • 2
0
votes
1 answer

SAS IML list of objects

In SAS IML I would like to pass a variable number of matices of numeric and character types and different dimensions to a user defined module. This can be implemented by e.g. creating a list of objects and pass the list to the module. For instance…
0
votes
1 answer

Access matrix columns by column name in a user-defined module

In an IML procedure I have a matrix with named columns. proc iml; myMatrix = {1 2 3, 1 4 9}; mattrib myMatrix colname={"a", "b", "c"}; print myMatrix; print (myMatrix[,"a"]); /* load module = myModule;*/ /* run…
0
votes
1 answer

How to do multiplication between two matrix using IML in SAS

I have data set named input_data below import from EXCEL. 0.353481635 0.704898683 0.078640917 0.813815803 0.510842666 0.240912872 0.986312218 0.781868961 0.682272971 0.443441526 0.653187181 0.753981865 0.34909803 0.84215961 0.793863082 0.047816942…
Elif Y
  • 251
  • 1
  • 4
  • 21
0
votes
1 answer

SAS simple Macro - Error

Why this very easy Macro programme : %macro test1(N=,NN=); proc iml; start fun_test(x) global(&NN,&N); x=&NN+&N; finish fun_test; call fun_test(x); print x; run; quit; %mend test1; %test1(N=10,NN=22); Gives the error? : 22 ERROR 22-322:…
Math
  • 1,274
  • 3
  • 14
  • 32
0
votes
2 answers

Inputting missing value in primary dataset based on values in secondary dataset and a matching condition

my understanding of SAS is very elementary. I am trying to do something like this and i need help. I have a primary dataset A with 20,000 observations where Col1 stores the CITY and Col2 stores the MILES. Col2 contains a lot of missing data. Which…
Tyrone Williams
  • 77
  • 1
  • 10
0
votes
2 answers

SAS IML constraining a called function

How do I properly constrain this minimizing function? Mincvf(cvf1) should minimize cvf1 with respect to h and I want to set so that h>=0.4 proc iml; EDIT kirjasto.basfraaka var "open"; read all var "open" into cp; p=cp[1:150]; conh={0.4 . .,. .…
0
votes
1 answer

SAS Proc IML rolling window (loop)

I wanted to modify this working module given below into this upper one with purpose that instead of using whole sample of p from 1 to m, the module would use only previous 18 and next 18 values around the time-point x. So p(x-18...x+18). But I end…
0
votes
1 answer

multiple if conditions within a loop in proc iml

I am using proc iml to manipulate the dataset. I am using if statement to check two conditions if the value is -7 or -8, I wrote this code below but the if statement is giving me errors because i am specifying the or condition incorrectly. Please…
bison2178
  • 747
  • 1
  • 8
  • 22
0
votes
1 answer

sas- compare components of a vector without a loop inside proc iml

I'm writing a code in proc iml and I want to run an if statement that evaluates each component of a vector and returns another vector but in one step. Is there any function to do so? Here's the code: proc iml; use chap0; read all var{X} into X; …
GabyLP
  • 3,649
  • 7
  • 45
  • 66
0
votes
1 answer

PROC IML trapezoidal rule

proc iml; start tr(x,y); * create function called tr; N = nrow(x); dx = x[2:N] - x[1:N-1]; ymean = (y[2:N] + y[1:N-1]) / 2; return(dx` * ymean ); finish tr; x = do(-2,5,0.01); print "Integral of a over x is" ( tr(x,0#x+1) ); *Answer is 7; I keep…