sas-iml

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

淺唱寂寞╮ 提交于 2020-01-17 08:22:07
问题 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 columns in matrices one can copypaste the mattrib statement enough times: /* mattrib mydata1 colname=names1;*/ /* mattrib mydata2 colname=names2;*/ However, in my case the number of matrices is defined at execution, thus a do loop is needed. The following code

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

会有一股神秘感。 提交于 2020-01-17 08:22:06
问题 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 columns in matrices one can copypaste the mattrib statement enough times: /* mattrib mydata1 colname=names1;*/ /* mattrib mydata2 colname=names2;*/ However, in my case the number of matrices is defined at execution, thus a do loop is needed. The following code

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

独自空忆成欢 提交于 2020-01-17 08:22:06
问题 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 columns in matrices one can copypaste the mattrib statement enough times: /* mattrib mydata1 colname=names1;*/ /* mattrib mydata2 colname=names2;*/ However, in my case the number of matrices is defined at execution, thus a do loop is needed. The following code

SAS IML pass reference to variable defined in macro

做~自己de王妃 提交于 2019-12-25 00:37:22
问题 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 is my code. proc iml; start funcReference(argOut); print "funcReference " argOut; argOut = 5; finish funcReference; store module=funcReference; quit; proc IML; mydata1 = {1 2 3}; call symput ('macVar', 'mydata1'); load module=funcReference; run

PROC IML trapezoidal rule

本小妞迷上赌 提交于 2019-12-13 08:34:31
问题 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 receiving the (execution) invalid subscript or subscript out of range. How do I solve this problem and get the correct answer? I've tried taking out the -1 in x[1:N-1]; and y[1:N-1], but it gives me the wrong answer. Is it because I need to assume

Loop over names in SAS-IML?

我的梦境 提交于 2019-12-02 03:56:15
问题 How can I read a SAS-Dataset with a name given as stem+suffix into IML? The stem is given as a SAS macro variable, the suffices I intend to use are in a string-vector in IML. In R I would use suffix<-c('s1','s2') for (s in suffix){ data<-eval(as.name(paste(stem,s,sep=''))) } I could do the looping if I had the code for the first dataset. I tried: proc iml; suffices = {'s1','s2'}; call symput('suffix',suffices[1]); use &stem.&suffix.; The problem being that if in a do-loop (and I need this as