Hi im trying to import to sas some tables that are in R named: table_1 , table_2 , table_3 etc.
I need to do this with a loop because the number of tables will depend of de number of rows of another table (table_w). i imagine it would be something like :
call ImportDataSetFromR("table_w","table_w");
do i=1 to nrow(table_w);
call ImportDataSetFromR("table_"&i,"table_"&i);
end;
but when i run it it has no errors but the are no tables in work.
thanks!
That syntax is not valid. There is no macro variable named 'i', so &i is null.
Also, you are importing table_w as a data set, so the expression nrow(table_a) equals 0. Maybe you meant to import it as a matrix?
I don't know what names you want to read, but here is some sample code that might help you figure it out.
proc iml;
table_w = {'A', 'My_results', 'More_results'};
do i=1 to nrow(table_w);
dsName = strip(table_w[i]);
print i dsName;
*call ImportDataSetFromR(dsName,dsName); /* uncomment when ready */
end;
/* or if the tables are named table_w1, table_w2, etc */
do i=1 to nrow(table_w);
dsName = "table_w" + strip(char(i));
print i dsName;
*call ImportDataSetFromR(dsName,dsName); /* uncomment when ready */
end;
@ManuelaVila I moved this thread to the IMl forum.
That syntax is not valid. There is no macro variable named 'i', so &i is null.
Also, you are importing table_w as a data set, so the expression nrow(table_a) equals 0. Maybe you meant to import it as a matrix?
I don't know what names you want to read, but here is some sample code that might help you figure it out.
proc iml;
table_w = {'A', 'My_results', 'More_results'};
do i=1 to nrow(table_w);
dsName = strip(table_w[i]);
print i dsName;
*call ImportDataSetFromR(dsName,dsName); /* uncomment when ready */
end;
/* or if the tables are named table_w1, table_w2, etc */
do i=1 to nrow(table_w);
dsName = "table_w" + strip(char(i));
print i dsName;
*call ImportDataSetFromR(dsName,dsName); /* uncomment when ready */
end;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.